From d152c5e358cad1241ce6cdcc302c1b2f3175f480 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Sun, 28 Jun 2009 13:55:50 +0200 Subject: Allow boolean value for boolean cli parameter This is to fix puppetdoc boolean parameters. Puppetdoc defers sending parameters to Puppet::Util::Setting, and in this case, boolean parameters are stored as a boolean value. Signed-off-by: Brice Figureau --- lib/puppet/util/settings.rb | 2 ++ spec/unit/util/settings.rb | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 4fbf602f6..0129fe705 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -830,6 +830,8 @@ Generated on #{Time.now}. when /^false$/i; false when /^true$/i; true when /^\d+$/i; Integer(value) + when true; true + when false; false else value.gsub(/^["']|["']$/,'').sub(/\s+$/, '') end diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb index c700c0c5f..5e9ab3a18 100755 --- a/spec/unit/util/settings.rb +++ b/spec/unit/util/settings.rb @@ -104,6 +104,13 @@ describe Puppet::Util::Settings do @settings[:bool].should == true end + it "should consider a cli setting with a boolean as an argument to be a boolean" do + # Turn it off first + @settings[:bool] = false + @settings.handlearg("--bool", true) + @settings[:bool].should == true + end + it "should clear the cache when setting getopt-specific values" do @settings.setdefaults :mysection, :one => ["whah", "yay"], :two => ["$one yay", "bah"] @settings[:two].should == "whah yay" -- cgit