Class: CloudstackClient::Cli
- Inherits:
-
Thor
- Object
- Thor
- CloudstackClient::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/cloudstack_client/cli.rb
Class Method Summary collapse
-
.start(given_args = ARGV, config = {}) ⇒ Object
rescue error globally.
Instance Method Summary collapse
Class Method Details
permalink .start(given_args = ARGV, config = {}) ⇒ Object
rescue error globally
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cloudstack_client/cli.rb', line 37 def self.start(given_args=ARGV, config={}) super rescue => e error_class = e.class.name.split('::') if error_class.size == 2 && error_class.first == "CloudstackClient" puts "\e[31mERROR\e[0m: #{error_class.last} - #{e.}" puts e.backtrace if ARGV.include? "--debug" else raise end end |
Instance Method Details
permalink #console ⇒ Object
[View source]
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cloudstack_client/cli.rb', line 92 def console cs_client = client() print "cloudstack_client version #{CloudstackClient::VERSION}" puts " (CloudStack API version #{cs_client.api.api_version})" puts " try: list_virtual_machines state: \"running\"" ARGV.clear Ripl.config[:prompt] = "#{@config[:environment]} >> " Ripl.start binding: cs_client.instance_eval{ binding } end |
permalink #list_apis ⇒ Object
[View source]
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cloudstack_client/cli.rb', line 64 def list_apis apis = client(no_api_methods: true).send_request('command' => 'listApis') apis.each do |command| command.delete("response") if [:remove_response] if [:remove_description] command.delete("description") command["params"].each {|param| param.delete("description")} end end print case [:format] when "yaml" apis.to_yaml else [:pretty_print] ? JSON.pretty_generate(apis) : JSON.generate(apis) end end |
permalink #version ⇒ Object
[View source]
50 51 52 |
# File 'lib/cloudstack_client/cli.rb', line 50 def version say "cloudstack_client version #{CloudstackClient::VERSION}" end |