12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/cloudstack-cli/cli.rb', line 12
def setup(file = options[:config])
config = {}
unless options[:url]
say "What's the URL of your Cloudstack API?", :blue
say "Example: https://my-cloudstack-server/client/api/", :blue
config[:url] = ask("URL:", :magenta)
end
unless options[:api_key]
config[:api_key] = ask("API Key:", :magenta)
end
unless options[: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
|