Class: CloudstackCli::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/cloudstack-cli/cli.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Instance Method Details
#command(command, *args) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/cloudstack-cli/cli.rb', line 46 def command(command, *args) client = CloudstackCli::Helper.new([:config]) params = {'command' => command} args.each do |arg| arg = arg.split('=') params[arg[0]] = arg[1] end puts JSON.pretty_generate(client.cs.send_request params) end |
#setup(file = options[:config]) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cloudstack-cli/cli.rb', line 22 def setup(file = [:config]) config = {} unless [:url] say "What's the URL of your Cloudstack API?", :yellow say "Example: https://my-cloudstack-server/client/api/", :yellow config[:url] = ask("URL:", :magenta) end unless [:api_key] config[:api_key] = ask("API Key:", :magenta) end unless [:secret_key] config[:secret_key] = ask("Secret Key:", :magenta) end if File.exists? file say "Warning: #{file} already exists.", :red exit unless yes?("Overwrite [y/N]", :red) end File.open(file, 'w+') {|f| f.write(config.to_yaml) } end |
#version ⇒ Object
14 15 16 |
# File 'lib/cloudstack-cli/cli.rb', line 14 def version say "cloudstack-cli v#{CloudstackCli::VERSION}" end |