Class: RightScaleCLI::Configure

Inherits:
Thor
  • Object
show all
Defined in:
lib/rightscale_cli/configure.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Configure

Returns a new instance of Configure.



30
31
32
33
34
35
36
# File 'lib/rightscale_cli/configure.rb', line 30

def initialize(*args)
  super
  @logger = RightScaleCLI::Logger.new()
  @template_path = File.join(File.dirname(__FILE__), '..', 'templates', '/right_api_client.yml.erb')
  @config = RightScaleCLI::Config.new
  @directives = {}
end

Class Method Details

default_task :all



97
98
99
# File 'lib/rightscale_cli/configure.rb', line 97

def self.banner(task, namespace = true, subcommand = false)
  "#{basename} #{task.formatted_usage(self, true, subcommand)}"
end

Instance Method Details

#accountObject



46
47
48
# File 'lib/rightscale_cli/configure.rb', line 46

def ()
  update_conf(@config.local.merge({:account_id => ask("RightScale account ID (e.g. 1337):")}))
end

#allObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rightscale_cli/configure.rb', line 76

def all()
  #directives = {
  #  :account_id => account(),
  #  :email => user(),
  #  :password_base64 => Base64.encode64(ask_pass).strip,
  #  :api_url => shard(),
  #  :api_version => api()
  #}
  #@logger.debug(directives)

  # currently this is the lazy way, each is written sequentially
  ()
  user()
  password()
  shard()
  api()
  puts 'Configuration saved.'
end

#apiObject



61
62
63
# File 'lib/rightscale_cli/configure.rb', line 61

def api()
  update_conf(@config.local.merge({:api_version => ask("RightScale API version (e.g. 1.5):")}))
end

#passwordObject



56
57
58
# File 'lib/rightscale_cli/configure.rb', line 56

def password()
  update_conf(@config.local.merge({:password_base64 => Base64.encode64(ask_pass).strip}))
end

#shardObject



66
67
68
# File 'lib/rightscale_cli/configure.rb', line 66

def shard()
  update_conf(@config.local.merge({:api_url => "https://#{ask("RightScale shard (e.g. us-4.rightscale.com):")}"}))
end

#showObject



71
72
73
# File 'lib/rightscale_cli/configure.rb', line 71

def show()
  puts @config.local
end

#userObject



51
52
53
# File 'lib/rightscale_cli/configure.rb', line 51

def user()
  update_conf(@config.local.merge({:email => ask("RightScale username (e.g. [email protected]):")}))
end