summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-08 20:54:49 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-08 20:54:49 +0000
commit1fc4ec373f8ee272077e2e78a380ac78879ffabe (patch)
treefbae3b75f9240c607f98c05485c55506c94d0c4a /lib
parentc90d0b1144c095ecd16f3e3243b003adc686675c (diff)
Fixing #167. Started with the submitted patch and made a few more modifications, and added a regression test.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1247 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/config.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/puppet/config.rb b/lib/puppet/config.rb
index 680c9f2fb..0569424e3 100644
--- a/lib/puppet/config.rb
+++ b/lib/puppet/config.rb
@@ -143,12 +143,7 @@ class Config
# Handle a command-line argument.
def handlearg(opt, value = nil)
- if value == "true"
- value = true
- end
- if value == "false"
- value = false
- end
+ value = mungearg(value)
str = opt.sub(/^--/,'')
bool = true
newstr = str.sub(/^no-/, '')
@@ -196,6 +191,18 @@ class Config
end
end
+ # Convert arguments appropriately.
+ def mungearg(value)
+ # Handle different data types correctly
+ return case value
+ when /^false$/i: false
+ when /^true$/i: true
+ when /^\d+$/i: Integer(value)
+ else
+ value
+ end
+ end
+
# Return all of the parameters associated with a given section.
def params(section)
section = section.intern if section.is_a? String
@@ -236,7 +243,7 @@ class Config
when /^\s*$/: next # Skip blanks
when /^\s*(\w+)\s*=\s*(.+)$/: # settings
var = $1.intern
- value = $2
+ value = mungearg($2)
# Mmm, "special" attributes
if metas.include?(var.to_s)