Class: Central::Cli::Master::UseCommand
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- Central::Cli::Master::UseCommand
show all
- Includes:
- Common
- Defined in:
- lib/central/cli/master/use_command.rb
Instance Method Summary
collapse
Methods included from Common
#access_token=, #add_master, #api_url, #api_url=, #clear_current_stack, #client, #current_master, #current_master=, #current_master_index, #current_stack, #current_stack=, #ensure_custom_ssl_ca, #require_api_url, #require_current_stack, #require_token, #reset_client, #save_settings, #settings, #settings_filename
Instance Method Details
#execute ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/central/cli/master/use_command.rb', line 7
def execute
master = find_master_by_name(name)
if !master.nil?
self.current_master = master['name']
puts "Using master: #{master['name'].cyan} (#{master['url']})"
puts "Using stack: #{current_stack.cyan}" if current_stack
stacks = client(require_token).get('stacks')['stacks']
if stacks.size > 1
puts ''
puts "You have access to following stacks and can switch between them using 'cm stack use <name>'"
puts ''
stacks.each do |stack|
puts " * #{stack['name']}"
end
puts ''
end
else
abort "Could not resolve master by name [#{name}]. For a list of known masters please run: cm master list".colorize(:red)
end
end
|
#find_master_by_name(name) ⇒ Object
28
29
30
31
32
|
# File 'lib/central/cli/master/use_command.rb', line 28
def find_master_by_name(name)
settings['servers'].each do |server|
return server if server['name'] == name
end
end
|