aboutsummaryrefslogtreecommitdiff
path: root/cli/lib/leap_cli/commands/pre.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-10-09 00:01:55 -0700
committerelijah <elijah@riseup.net>2012-10-09 00:01:55 -0700
commit578ac2f5dc7432317d7a022bed9d869ab89ee45c (patch)
tree3cf8d27c2e8059df33e33e9c39146e0b3db29599 /cli/lib/leap_cli/commands/pre.rb
parent105fe22c2de06310e48c4827b47d38d18750ed32 (diff)
downloadleap_cli-578ac2f5dc7432317d7a022bed9d869ab89ee45c.tar.gz
leap_cli-578ac2f5dc7432317d7a022bed9d869ab89ee45c.tar.bz2
initial code commit
Diffstat (limited to 'cli/lib/leap_cli/commands/pre.rb')
-rw-r--r--cli/lib/leap_cli/commands/pre.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/cli/lib/leap_cli/commands/pre.rb b/cli/lib/leap_cli/commands/pre.rb
new file mode 100644
index 0000000..ae58fc8
--- /dev/null
+++ b/cli/lib/leap_cli/commands/pre.rb
@@ -0,0 +1,38 @@
+
+#
+# check to make sure we can find the root directory of the platform
+#
+module LeapCli
+ module Commands
+
+ desc 'Verbosity level 0..2'
+ arg_name 'level'
+ default_value '0'
+ flag [:v, :verbose]
+
+ desc 'Specify the root directory'
+ arg_name 'path'
+ default_value Path.root
+ flag [:root]
+
+ pre do |global,command,options,args|
+ #
+ # set verbosity
+ #
+ LeapCli.log_level = global[:verbose].to_i
+
+ #
+ # require a root directory
+ #
+ if global[:root]
+ Path.set_root(global[:root])
+ end
+ if Path.ok?
+ true
+ else
+ exit_now!("Could not find the root directory. Change current working directory or try --root")
+ end
+ end
+
+ end
+end