diff options
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 | 
