21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/razor/cli/format.rb', line 21
def format_document(doc, parse = nil)
format = parse && parse.format
arguments = parse && parse.stripped_args
doc = Razor::CLI::Document.new(doc, format)
return _("There are no items for this query.") if doc.items.empty?
return format_command_help(doc, parse.show_api_help?) if parse && parse.show_command_help?
case (doc.format_view['+layout'] or 'list')
when 'list'
format_objects(doc.items) + String(additional_details(doc, parse, arguments)).chomp
when 'table'
case doc.items
when Array then
get_table(doc.items, doc.format_view) + String(additional_details(doc, parse, arguments))
else doc.to_s
end
else
raise ArgumentError, _("Unrecognized view format %{format_name}") % {format_name: doc.format_view['+layout']}
end
end
|