mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
Parse CLI inputs as booleans
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
786e3728d7
commit
849bd90930
1 changed files with 6 additions and 3 deletions
|
@ -179,11 +179,14 @@ module Inspec
|
|||
# Remove trailing commas, resolve type.
|
||||
def parse_cli_input_value(input_name, given_value)
|
||||
value = given_value.chomp(",") # Trim trailing comma if any
|
||||
if value =~ /^-?\d+$/
|
||||
case value
|
||||
when /^true|false$/
|
||||
value = value == "true"
|
||||
when /^-?\d+$/
|
||||
value = value.to_i
|
||||
elsif value =~ /^-?\d+\.\d+$/
|
||||
when /^-?\d+\.\d+$/
|
||||
value = value.to_f
|
||||
elsif value =~ /^(\[|\{).*(\]|\})$/
|
||||
when /^(\[|\{).*(\]|\})$/
|
||||
# Look for complex values and try to parse them.
|
||||
require "yaml"
|
||||
begin
|
||||
|
|
Loading…
Reference in a new issue