diff options
author | Daniel DeLeo <dan@opscode.com> | 2010-06-12 23:20:46 -0700 |
---|---|---|
committer | Daniel DeLeo <dan@opscode.com> | 2010-06-12 23:20:46 -0700 |
commit | 974f34fa8befdf14ace356e4a31a9ed2edb62f86 (patch) | |
tree | 233b00b2b67100065a59ceabbaa0fb956d2ae0e4 /chef | |
parent | d5f499a8bc84ed86e79cb93258ec1bb40aff9408 (diff) | |
download | chef-974f34fa8befdf14ace356e4a31a9ed2edb62f86.tar.gz |
support showing usage in knife base
Diffstat (limited to 'chef')
-rw-r--r-- | chef/lib/chef/knife.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/chef/lib/chef/knife.rb b/chef/lib/chef/knife.rb index de04fb45f3..b06170b187 100644 --- a/chef/lib/chef/knife.rb +++ b/chef/lib/chef/knife.rb @@ -46,7 +46,7 @@ class Chef load_commands @sub_classes.keys.sort.each do |snake_case| klass_instance = build_sub_class(snake_case) - klass_instance.parse_options + klass_instance.parse_options([]) puts klass_instance.opt_parser puts end @@ -98,6 +98,14 @@ class Chef klass_instance end + def parse_options(args) + super + rescue OptionParser::InvalidOption => e + puts "Error: " + e.to_s + show_usage + exit(1) + end + def ask_question(question, opts={}) question = question + "[#{opts[:default]}] " if opts[:default] @@ -244,6 +252,10 @@ class Chef end end + def show_usage + stdout.puts("USAGE: " + self.opt_parser.to_s) + end + def load_from_file(klass, from_file, bag=nil) relative_path = "" if klass == Chef::Role |