summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chef/lib/chef/knife.rb14
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