Method: Gitlab::CLI::Helpers.output_json
- Defined in:
- lib/gitlab/cli_helpers.rb
permalink .output_json(cmd, args, data) ⇒ Object
[View source]
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/gitlab/cli_helpers.rb', line 108 def output_json(cmd, args, data) if data.respond_to?(:empty?) && data.empty? puts '{}' else hash_result = case data when Gitlab::ObjectifiedHash, Gitlab::FileResponse record_hash([data], cmd, args, single_value: true) when Gitlab::PaginatedResponse record_hash(data, cmd, args) else { cmd: cmd, data: data, args: args } end puts JSON.pretty_generate(hash_result) end end |