Class: Kanmon::CLI
- Inherits:
-
Thor
- Object
- Thor
- Kanmon::CLI
- Defined in:
- lib/kanmon/cli.rb
Instance Method Summary collapse
- #close ⇒ Object
- #exec(*args) ⇒ Object
- #list ⇒ Object
- #open ⇒ Object
- #ssh(*args) ⇒ Object
- #version ⇒ Object
Instance Method Details
#close ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/kanmon/cli.rb', line 28 def close if [:all] && [:target].nil? config.targets.each do |name| puts "Checking #{name}" config.set(name) adapter = load_adapter(config) adapter.close end else adapter = load_adapter(config) adapter.close end puts "Success!!" end |
#exec(*args) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/kanmon/cli.rb', line 50 def exec(*args) adapter = load_adapter(config) adapter.open do command = Shellwords.join(args) Process.wait spawn(command) end end |
#list ⇒ Object
59 60 61 |
# File 'lib/kanmon/cli.rb', line 59 def list puts config.targets.sort.join("\n") end |
#open ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/kanmon/cli.rb', line 16 def open adapter = load_adapter(config) adapter.open puts "Success!!" rescue Yao::Conflict => e puts "Is not it already opened?" if e..include?("Security group rule already exists.") puts e rescue Kanmon::AlreadySecurityExistsError end |
#ssh(*args) ⇒ Object
44 45 46 47 |
# File 'lib/kanmon/cli.rb', line 44 def ssh(*args) ssh_args = args.unshift("ssh", [:target]) invoke :exec, ssh_args end |
#version ⇒ Object
64 65 66 |
# File 'lib/kanmon/cli.rb', line 64 def version puts Kanmon::VERSION end |