class CloudstackCli::Cli

Public Instance Methods

command(command, *args) click to toggle source
   # File lib/cloudstack-cli/cli.rb
53 def command(command, *args)
54   params = { 'command' => command }
55   args.each do |arg|
56     arg = arg.split('=')
57     params[arg[0]] = arg[1]
58   end
59 
60   unless client.api.commands.has_key? command
61     say "ERROR: ", :red
62     say "Unknown API command '#{command}'."
63     exit!
64   end
65 
66   unless client.api.all_required_params?(command, params)
67     raise CloudstackClient::ParameterError, client.api.missing_params_msg(command)
68   end
69 
70   data = client.send_request(params)
71   if options[:format] == 'json'
72     puts options[:pretty_print] ? JSON.pretty_generate(data) : data.to_json
73   else
74     puts data.to_yaml
75   end
76 end
completion() click to toggle source
   # File lib/cloudstack-cli/cli.rb
36 def completion
37   shell_script = File.join(
38     File.dirname(__FILE__), '..', '..',
39     'completions', "cloudstack-cli.#{options[:shell]}"
40   )
41   unless File.file? shell_script
42     say "Specified cloudstack-cli shell auto-completion rules for #{options[:shell]} not found.", :red
43     exit 1
44   end
45   puts File.read shell_script
46 end
setup(env = options[:environment]) click to toggle source
   # File lib/cloudstack-cli/cli.rb
29 def setup(env = options[:environment])
30   invoke "environment:add", [env],
31     :config_file => options[:config_file]
32 end
version() click to toggle source
   # File lib/cloudstack-cli/cli.rb
23 def version
24   say "cloudstack-cli version #{CloudstackCli::VERSION}"
25   say " (cloudstack_client version #{CloudstackClient::VERSION})"
26 end