27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/routes/switch.rb', line 27
def opts_routing
config_file = File.expand_path(App::CONFIG_FILE)
Blufin::Terminal::error("File not found: #{Blufin::Terminal::format_invalid(config_file)}") unless Blufin::Files::file_exists(config_file)
profiles = []
App::AWSProfile::get_profile_names.each do |profile|
option = {
:text => profile,
:value => profile
}
profiles << option
end
Blufin::Terminal::info("Current profile: #{Blufin::Terminal::format_highlight(App::AWSProfile::get_profile_name)}")
new_profile = Blufin::Terminal::prompt_select('Select a profile', profiles)
Blufin::Files::write_line_to_file(config_file, "DefaultProfile: #{new_profile}", /^\s*DefaultProfile:/, false, true)
Blufin::Terminal::success("Your new active profile is: #{Blufin::Terminal::format_highlight(new_profile)}", "All #{Blufin::Terminal::format_command('awx')} commands will now run against this profile.")
if App::is_albert_mac
config_file = App::CONFIG_FILE
symlinked_file = Blufin::Config::get['CustomOptions']['ConfigFilePath']
Blufin::Terminal::error("File not found: #{Blufin::Terminal::format_invalid(symlinked_file)}", "A symlink to #{Blufin::Terminal::format_directory(config_file)} was broken and could not be re-created.") unless Blufin::Files::file_exists(symlinked_file)
res = []
res[0] = Blufin::Terminal::execute("cp #{File.expand_path(config_file)} #{File.expand_path(symlinked_file)} ")
res[1] = Blufin::Terminal::execute("ln -sfv #{File.expand_path(symlinked_file)} #{File.expand_path(config_file)}")
puts
puts "\x1B[38;5;240m File successfully copied/symlinked.\x1B[0m" if res[0] && res[1]
puts "\x1B[38;5;196m Something went wrong. The cp/symlink command(s) did not return successful exit code(s).\x1B[0m" if !res[0] || !res[1]
puts
end
end
|