lib/hammer_cli/output/formatters.rb in hammer_cli-0.5.1 vs lib/hammer_cli/output/formatters.rb in hammer_cli-0.6.0
- old
+ new
@@ -91,17 +91,23 @@
""
end
end
class ListFormatter < FieldFormatter
+ INDENT = " "
def tags
[:flat]
end
def format(list, field_params={})
if list.is_a? Array
- list.join(", ")
+ separator = field_params.fetch(:separator, ', ')
+ new_line = field_params.fetch(:on_new_line, false)
+
+ list = list.join(separator)
+ list ="\n#{list.indent_with(INDENT)}" if new_line
+ list
elsif list
list.to_s
else
""
end