summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorZack Hobson2013-12-27 10:15:53 -0800
committerZack Hobson2013-12-27 10:15:53 -0800
commitf0eee83fcdf3047674db3310f2847704021e54e1 (patch)
treedb69f1eeb08c84d9a07b3c1437eba7b918ba7bf1 /lib
parent1d4c84a906df99e12ecf4ae1aa04260eb737d550 (diff)
downloadhcl-f0eee83fcdf3047674db3310f2847704021e54e1.tar.bz2
console command
Diffstat (limited to 'lib')
-rw-r--r--lib/hcl.rb1
-rw-r--r--lib/hcl/commands.rb6
-rw-r--r--lib/hcl/console.rb19
3 files changed, 26 insertions, 0 deletions
diff --git a/lib/hcl.rb b/lib/hcl.rb
index 5d6f108..b041538 100644
--- a/lib/hcl.rb
+++ b/lib/hcl.rb
@@ -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