summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-06 16:37:29 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-06 16:37:29 -0700
commit91069f36bcfe5b67f2ef0189360d55b607438c92 (patch)
tree66eebc03390c427db1a1579e7093b3e014edb012 /lib/puppet/application
parentf732d69552969698fdae7905284f01682bfd3441 (diff)
parent27bd1adb7cc43bfdeb8fb941418cfce3a7f694ef (diff)
downloadpuppet-91069f36bcfe5b67f2ef0189360d55b607438c92.tar.gz
puppet-91069f36bcfe5b67f2ef0189360d55b607438c92.tar.xz
puppet-91069f36bcfe5b67f2ef0189360d55b607438c92.zip
Merge branch 'bug/master/6972-setting-CA-location-for-cert-string-no-longer-works'
Diffstat (limited to 'lib/puppet/application')
-rw-r--r--lib/puppet/application/certificate.rb15
-rw-r--r--lib/puppet/application/string_base.rb22
2 files changed, 24 insertions, 13 deletions
diff --git a/lib/puppet/application/certificate.rb b/lib/puppet/application/certificate.rb
index f4b13ffe0..eacb830b2 100644
--- a/lib/puppet/application/certificate.rb
+++ b/lib/puppet/application/certificate.rb
@@ -1,18 +1,10 @@
require 'puppet/application/indirection_base'
class Puppet::Application::Certificate < Puppet::Application::IndirectionBase
-
- # Luke used to call this --ca but that's taken by the global boolean --ca.
- # Since these options map CA terminology to indirector terminology, it's
- # now called --ca-location.
- option "--ca-location CA_LOCATION" do |arg|
- Puppet::SSL::Host.ca_location = arg.to_sym
- end
-
def setup
-
- unless Puppet::SSL::Host.ca_location
- raise ArgumentError, "You must have a CA location specified; use --ca-location to specify the location (remote, local, only)"
+ unless options[:ca_location]
+ raise ArgumentError, "You must have a CA location specified;\n" +
+ "use --ca-location to specify the location (remote, local, only)"
end
location = Puppet::SSL::Host.ca_location
@@ -23,5 +15,4 @@ class Puppet::Application::Certificate < Puppet::Application::IndirectionBase
super
end
-
end
diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb
index 76b0a46fd..09d02c079 100644
--- a/lib/puppet/application/string_base.rb
+++ b/lib/puppet/application/string_base.rb
@@ -68,7 +68,9 @@ class Puppet::Application::StringBase < Puppet::Application
until @action or (index += 1) >= command_line.args.length do
item = command_line.args[index]
if item =~ /^-/ then
- option = @string.options.find { |a| item =~ /^-+#{a}\b/ }
+ option = @string.options.find do |name|
+ item =~ /^-+#{name.to_s.gsub(/[-_]/, '[-_]')}(?:[ =].*)?$/
+ end
if option then
option = @string.get_option(option)
# If we have an inline argument, just carry on. We don't need to
@@ -79,6 +81,12 @@ class Puppet::Application::StringBase < Puppet::Application
index += 1 unless
(option.optional_argument? and command_line.args[index + 1] =~ /^-/)
end
+ elsif option = find_global_settings_argument(item) then
+ unless Puppet.settings.boolean? option.name then
+ # As far as I can tell, we treat non-bool options as always having
+ # a mandatory argument. --daniel 2011-04-05
+ index += 1 # ...so skip the argument.
+ end
else
raise ArgumentError, "Unknown option #{item.sub(/=.*$/, '').inspect}"
end
@@ -101,6 +109,18 @@ class Puppet::Application::StringBase < Puppet::Application
end
end
+ def find_global_settings_argument(item)
+ Puppet.settings.each do |name, object|
+ object.optparse_args.each do |arg|
+ next unless arg =~ /^-/
+ # sadly, we have to emulate some of optparse here...
+ pattern = /^#{arg.sub('[no-]', '').sub(/[ =].*$/, '')}(?:[ =].*)?$/
+ pattern.match item and return object
+ end
+ end
+ return nil # nothing found.
+ end
+
def setup
Puppet::Util::Log.newdestination :console