Class: HammerCLI::Options::Normalizers::List
Class Method Summary
collapse
Instance Method Summary
collapse
#complete, #completion_type, #description, inherited
Class Method Details
.common_description ⇒ Object
127
128
129
130
131
|
# File 'lib/hammer_cli/options/normalizers.rb', line 127
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
123
124
125
|
# File 'lib/hammer_cli/options/normalizers.rb', line 123
def completion_type
:list
end
|
Instance Method Details
134
135
136
137
138
139
140
141
|
# File 'lib/hammer_cli/options/normalizers.rb', line 134
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
|