diff options
| author | Zack Hobson | 2013-12-27 10:15:53 -0800 |
|---|---|---|
| committer | Zack Hobson | 2013-12-27 10:15:53 -0800 |
| commit | f0eee83fcdf3047674db3310f2847704021e54e1 (patch) | |
| tree | db69f1eeb08c84d9a07b3c1437eba7b918ba7bf1 /lib | |
| parent | 1d4c84a906df99e12ecf4ae1aa04260eb737d550 (diff) | |
| download | hcl-f0eee83fcdf3047674db3310f2847704021e54e1.tar.bz2 | |
console command
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/hcl.rb | 1 | ||||
| -rw-r--r-- | lib/hcl/commands.rb | 6 | ||||
| -rw-r--r-- | lib/hcl/console.rb | 19 |
3 files changed, 26 insertions, 0 deletions
@@ -3,6 +3,7 @@ module HCl autoload :App, 'hcl/app' autoload :Net, 'hcl/net' autoload :Commands, 'hcl/commands' + autoload :Console, 'hcl/console' autoload :TimesheetResource, 'hcl/timesheet_resource' autoload :Utility, 'hcl/utility' autoload :Project, 'hcl/project' diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb index 98daff5..3e96077 100644 --- a/lib/hcl/commands.rb +++ b/lib/hcl/commands.rb @@ -1,5 +1,6 @@ require 'chronic' require 'highline' +require 'pry' module HCl module Commands @@ -10,6 +11,11 @@ module HCl Net.config_hash.merge(password:'***').map {|k,v| "#{k}: #{v}" }.join("\n") end + def console + Console.new(self) + nil + end + def tasks project_code=nil tasks = Task.all if tasks.empty? # cache tasks diff --git a/lib/hcl/console.rb b/lib/hcl/console.rb new file mode 100644 index 0000000..da0f7c5 --- /dev/null +++ b/lib/hcl/console.rb @@ -0,0 +1,19 @@ +require 'pp' + +module HCl + class Console + attr_reader :hcl + def initialize app + @hcl = app + binding.pry quiet: true, + prompt:[->(a,b,c){"#{$PROGRAM_NAME}> "}], + print:->(io, *p){ pp p } + end + + Commands.instance_methods.each do |command| + define_method command do |*args| + puts @hcl.send(command, *args) + end + end + end +end |
