diff options
author | Dan Bode <dan@puppetlabs.com> | 2011-07-06 21:59:05 -0700 |
---|---|---|
committer | Jeff McCune <jeff@puppetlabs.com> | 2011-07-10 13:03:53 -0700 |
commit | ae3ef423c03b7ef27f975dadfb67bf77ca481503 (patch) | |
tree | b3ecb26b570730e825c0a4005913ff7370511477 | |
parent | 8fe2e555ac3d57f5b6503ffe1a5466db8d6e190a (diff) | |
download | puppet-ae3ef423c03b7ef27f975dadfb67bf77ca481503.tar.gz puppet-ae3ef423c03b7ef27f975dadfb67bf77ca481503.tar.xz puppet-ae3ef423c03b7ef27f975dadfb67bf77ca481503.zip |
(#7699) - Help should only show options once
puppet help was reprinting every option once
for every alias that is had.
This fix involves only storing the option.name
in the @options instance var for both face and
actions options. The @options_hash still
maintains the list of options and aliases as its
keys.
Reviewed-by: Daniel Pittman (puppet-dev list)
-rw-r--r-- | lib/puppet/interface/action.rb | 3 | ||||
-rw-r--r-- | lib/puppet/interface/option_manager.rb | 3 | ||||
-rwxr-xr-x | spec/unit/interface/action_spec.rb | 9 | ||||
-rwxr-xr-x | spec/unit/interface_spec.rb | 8 |
4 files changed, 21 insertions, 2 deletions
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 185302b07..fe77a9658 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -227,8 +227,9 @@ WRAPPER end end + @options << option.name + option.aliases.each do |name| - @options << name @options_hash[name] = option end diff --git a/lib/puppet/interface/option_manager.rb b/lib/puppet/interface/option_manager.rb index 326a91d92..a1f300e8e 100644 --- a/lib/puppet/interface/option_manager.rb +++ b/lib/puppet/interface/option_manager.rb @@ -26,8 +26,9 @@ module Puppet::Interface::OptionManager end end + @options << option.name + option.aliases.each do |name| - @options << name @options_hash[name] = option end diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb index cf8d61d51..3e1bd0d4c 100755 --- a/spec/unit/interface/action_spec.rb +++ b/spec/unit/interface/action_spec.rb @@ -171,6 +171,15 @@ describe Puppet::Interface::Action do face.get_action(:foo).options.should =~ [:bar] end + it "should only list options and not aliases" do + face = Puppet::Interface.new(:action_level_options, '0.0.1') do + action :foo do + option "--bar", "-b", "--foo-bar" + end + end + face.get_action(:foo).options.should =~ [:bar] + end + describe "with both face and action options" do let :face do Puppet::Interface.new(:action_level_options, '0.0.1') do diff --git a/spec/unit/interface_spec.rb b/spec/unit/interface_spec.rb index 8bbbcc857..4cb1f8743 100755 --- a/spec/unit/interface_spec.rb +++ b/spec/unit/interface_spec.rb @@ -174,6 +174,14 @@ describe Puppet::Interface do face.get_action(:foo).options.should =~ [:quux] face.get_action(:bar).options.should =~ [:quux] end + + it "should only list options and not aliases" do + face = subject.new(:face_options, '0.0.1') do + option "--bar", "-b", "--foo-bar" + end + face.options.should =~ [:bar] + end + end describe "with inherited options" do |