21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/superbot/cloud/cli/webdriver/list_command.rb', line 21
def list_sessions
states = all? ? nil : %w[idle proxying]
api_response = Superbot::Cloud::Api.request(:webdriver_session_list, params: { organization_name: organization, 'aasm_state[]': states })
abort "No active sessions found for #{api_response[:organization]} organization" if api_response[:webdriver_sessions].empty?
if quiet?
puts(api_response[:webdriver_sessions].map { |session| session[:session_id] })
else
puts "Organization: #{api_response[:organization]}"
puts OUTPUT_HEADERS.values.map { || .ljust(35) }.join
puts ''.ljust(35 * OUTPUT_HEADERS.length, '-')
api_response[:webdriver_sessions].each do |webdriver_session|
puts webdriver_session.slice(*OUTPUT_HEADERS.keys).values.map { |v| v.to_s.ljust(35) }.join
end
end
end
|