Class: HammerCLI::Options::Normalizers::List
Class Method Summary
collapse
Instance Method Summary
collapse
#complete, #completion_type, #description, inherited
Class Method Details
.common_description ⇒ Object
132
133
134
135
136
|
# File 'lib/hammer_cli/options/normalizers.rb', line 132
def common_description
_('Comma separated list of values. Values containing comma should be quoted or escaped with backslash.') +
"\n" +
_('JSON is acceptable and preferred way for such parameters')
end
|
.completion_type ⇒ Object
128
129
130
|
# File 'lib/hammer_cli/options/normalizers.rb', line 128
def completion_type
:list
end
|
Instance Method Details
139
140
141
142
143
144
145
146
|
# File 'lib/hammer_cli/options/normalizers.rb', line 139
def format(val)
return [] unless val.is_a?(String) && !val.empty?
begin
[JSON.parse(val)].flatten(1)
rescue JSON::ParserError
HammerCLI::CSVParser.new.parse(val)
end
end
|