Class: CloudstackClient::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/cloudstack_client/cli.rb

Instance Method Summary collapse

Instance Method Details

#consoleObject



72
73
74
75
76
77
78
79
# File 'lib/cloudstack_client/cli.rb', line 72

def console
  puts "cloudstack_client version #{CloudstackClient::VERSION}"
  puts '  try: list_virtual_machines state: "Started"'
  ARGV.clear
  env = options[:env] ? options[:env] : load_configuration.last
  Ripl.config[:prompt] = "#{env} >> "
  Ripl.start binding: client.instance_eval('binding')
end

#list_apisObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cloudstack_client/cli.rb', line 51

def list_apis
  apis = client(no_api_methods: true).send_request('command' => 'listApis')
  apis.each do |command|
    command.delete("response") if options[:remove_response]
    if options[:remove_description]
      command.delete("description")
      command["params"].each {|param| param.delete("description")}
    end
  end

  print case options[:format]
  when "json"
    options[:pretty_print] ? JSON.pretty_generate(apis) : apis.to_json
  when "yaml"
    apis.to_yaml
  else
    apis.to_msgpack
  end
end

#versionObject



37
38
39
# File 'lib/cloudstack_client/cli.rb', line 37

def version
  say "cloudstack_client version #{CloudstackClient::VERSION}"
end