From 14b1e008c1368e6c56d68f83999472351fd3327a Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Mon, 11 Apr 2011 10:57:06 -0700 Subject: (#6992) Expose available_subcommands as a class method. We previously treated the list of legacy commands as an instance property of Puppet::Util::CommandLine. This made it difficult to obtain that information outside the context of the instantiated application. In the longer term this should wither and die as we eliminate the legacy applications entirely, but until then exposing that on the class is the lightest mechanism for making that useful. Paired-With: Matt Robinson --- spec/unit/util/command_line_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'spec/unit/util') diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb index ca5f0540f..c5c6e5f3e 100755 --- a/spec/unit/util/command_line_spec.rb +++ b/spec/unit/util/command_line_spec.rb @@ -111,6 +111,11 @@ describe Puppet::Util::CommandLine do @core_apps = %w{describe filebucket kick queue resource agent cert apply doc master} @command_line = Puppet::Util::CommandLine.new("foo", %w{ client --help whatever.pp }, @tty ) end + it "should expose available_subcommands as a class method" do + @core_apps.each do |command| + @command_line.available_subcommands.should include command + end + end it 'should be able to find all existing commands' do @core_apps.each do |command| @command_line.available_subcommands.should include command -- cgit From 826d5dff531eb624fef91a7298932e9ec5a46231 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Mon, 11 Apr 2011 23:09:18 -0700 Subject: (#6962) delegate global usage to the help face. The global --help handler (also invoked when puppet is run without any other command line options at all) used to spit out a brief and generally not so helpful message. Now that we have a help face that can provide the same information in a much more user-friendly form, we should delegate the function to that when required. Reviewed-By: Matt Robinson --- spec/unit/util/command_line_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'spec/unit/util') diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb index c5c6e5f3e..6cf90475b 100755 --- a/spec/unit/util/command_line_spec.rb +++ b/spec/unit/util/command_line_spec.rb @@ -99,10 +99,11 @@ describe Puppet::Util::CommandLine do Puppet::Util.expects(:which).with('puppet-whatever').returns(nil) commandline.expects(:system).never - commandline.expects(:usage_message).returns("the usage message") - commandline.expects(:abort).with{|x| x =~ /the usage message/}.raises("stubbed abort") + text = Puppet::Faces[:help, :current].help + commandline.expects(:puts).with { |x| x =~ /Unknown Puppet subcommand/ } + commandline.expects(:puts).with text - lambda{ commandline.execute }.should raise_error('stubbed abort') + commandline.execute end end end -- cgit