diff options
| -rw-r--r-- | CHANGELOG | 4 | ||||
| -rw-r--r-- | lib/hcl/app.rb | 2 | ||||
| -rw-r--r-- | lib/hcl/commands.rb | 6 | ||||
| -rw-r--r-- | lib/hcl/timesheet_resource.rb | 8 |
4 files changed, 18 insertions, 2 deletions
@@ -1,5 +1,9 @@ = Recent Changes in HCl +== next version + +* addded `config` command to display current credentials + == v0.4.9 2013-12-21 * MacOS X: store password in default keychain diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb index e58921f..18d293c 100644 --- a/lib/hcl/app.rb +++ b/lib/hcl/app.rb @@ -158,7 +158,7 @@ EOM config['login'] = ask("Email Address: ").to_s config['password'] = ask("Password: ") { |q| q.echo = false }.to_s config['subdomain'] = ask("Subdomain: ").to_s - config['ssl'] = %w(y yes).include?(ask("Use SSL? (y/n): ").downcase) + config['ssl'] = /^y/.match(ask("Use SSL? (y/n): ").downcase) TimesheetResource.configure config write_config config end diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb index 024d595..e9fd847 100644 --- a/lib/hcl/commands.rb +++ b/lib/hcl/commands.rb @@ -5,6 +5,12 @@ module HCl module Commands class Error < StandardError; end + # Display a sanitized view of your auth credentials. + def config + TimesheetResource.config_hash.merge(password:'***'). + map {|k,v| "#{k}: #{v}" }.join("\n") + end + def tasks project_code=nil tasks = Task.all if tasks.empty? # cache tasks diff --git a/lib/hcl/timesheet_resource.rb b/lib/hcl/timesheet_resource.rb index 1b2fefd..8fa7f5c 100644 --- a/lib/hcl/timesheet_resource.rb +++ b/lib/hcl/timesheet_resource.rb @@ -24,7 +24,8 @@ module HCl end # configuration accessors - %w[ login password subdomain ssl ].each do |config_var| + CONFIG_VARS = [ :login, :password, :subdomain, :ssl ].freeze + CONFIG_VARS.each do |config_var| class_eval <<-EOC def self.#{config_var}= arg @@#{config_var} = arg @@ -35,6 +36,11 @@ module HCl EOC end + # @return [Hash] + def self.config_hash + CONFIG_VARS.inject({}) {|c,k| c.update(k => TimesheetResource.send(k)) } + end + def initialize params @data = params end |
