7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/shuttle/cli.rb', line 7
def self.run
prompt = TTY::Prompt.new(interrupt: :signal)
begin
shuttle_config = JSON.parse(File.read("#{ENV['HOME']}/.shuttle.json"))
categories = shuttle_config['hosts']
while categories.size == 1
key = prompt.select('Category:', categories[0].keys)
categories = categories[0][key]
end
node = prompt.select('Node:', categories.map { |c| c['title'] })
selected_node = categories.detect { |c| c['title'] == node }
puts "Connecting to: #{selected_node['cmd']}"
exec(selected_node['cmd'])
rescue Interrupt => e
puts ''
puts 'Bye bye... 🐗'
end
end
|