Class: Kanmon::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/kanmon/cli.rb

Instance Method Summary collapse

Instance Method Details

#closeObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kanmon/cli.rb', line 28

def close
  if options[:all] && options[: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

#listObject



59
60
61
# File 'lib/kanmon/cli.rb', line 59

def list
  puts config.targets.sort.join("\n")
end

#openObject



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.message.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", options[:target])
  invoke :exec, ssh_args
end

#versionObject



64
65
66
# File 'lib/kanmon/cli.rb', line 64

def version
  puts Kanmon::VERSION
end