diff options
author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-11 17:11:25 -0700 |
---|---|---|
committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-12 16:12:09 -0700 |
commit | 648e3c0dd0fb671b01e54cc0bca202bafc5ae934 (patch) | |
tree | 21ac360d9645d057c2312207a50a9d48180ae0ab /lib/puppet | |
parent | 217c1561a86a76b9570bcc4ab0db31eb25d120fa (diff) | |
download | puppet-648e3c0dd0fb671b01e54cc0bca202bafc5ae934.tar.gz puppet-648e3c0dd0fb671b01e54cc0bca202bafc5ae934.tar.xz puppet-648e3c0dd0fb671b01e54cc0bca202bafc5ae934.zip |
(#6962) Better argument checking for help.
We used to blink and miss the fact that we failed to load an action or face in
the past; now we test for that, and fail with a clear error message when the
user asks for something we can't deliver.
Additionally, fix a couple of tests that were silently broken because they
passed the wrong arguments, but still got some output.
Paired-With: Matt Robinson <matt@puppetlabs.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/faces/help.rb | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/puppet/faces/help.rb b/lib/puppet/faces/help.rb index 26f839735..29a4a62f7 100644 --- a/lib/puppet/faces/help.rb +++ b/lib/puppet/faces/help.rb @@ -38,13 +38,19 @@ Puppet::Faces.define(:help, '0.0.1') do face = facename ? Puppet::Faces[facename.to_sym, version] : nil action = (face and actionname) ? face.get_action(actionname.to_sym) : nil - template = case args.length - when 0 then erb 'global.erb' - when 1 then erb 'face.erb' - when 2 then erb 'action.erb' - else - fail ArgumentError, "Too many arguments to help action" - end + case args.length + when 0 then + template = erb 'global.erb' + when 1 then + face or fail ArgumentError, "Unable to load face #{facename}" + template = erb 'face.erb' + when 2 then + face or fail ArgumentError, "Unable to load face #{facename}" + action or fail ArgumentError, "Unable to load action #{actionname} from #{face}" + template = erb 'action.erb' + else + fail ArgumentError, "Too many arguments to help action" + end # Run the ERB template in our current binding, including all the local # variables we established just above. --daniel 2011-04-11 |