24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/superbot/cloud/cli/run/list_command.rb', line 24
def list_interactive_runs
states = all? ? nil : %w[initial running]
api_response = Superbot::Cloud::Api.request(:interactive_run_list, params: { organization_name: organization, 'aasm_state[]': states })
abort api_response[:error] if api_response[:error]
abort "No active interactive runs found for organization #{api_response[:organization]}" if api_response[:interactive_runs].empty?
if quiet?
puts(api_response[:interactive_runs].map { |interactive_run| interactive_run[:id] })
else
puts "Organization: #{api_response[:organization]}"
puts "Interactive runs:"
puts OUTPUT_HEADERS.values.map { || [:name].ljust([:column_size]) }.join
api_response[:interactive_runs].each do |interactive_run|
row = interactive_run.slice(*OUTPUT_HEADERS.keys).map do |key, value|
value.to_s.ljust(OUTPUT_HEADERS.dig(key, :column_size))
end.join
puts row
end
end
end
|