Class: Tunnel::CLI

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

Instance Method Summary collapse

Instance Method Details

#addObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tunnel/cli.rb', line 26

def add
  highline = HighLine.new
  puts "Adding a new tunnel config"

  conf = Config.new
  conf.name        = highline.ask("Name:        ")
  conf.ssh_port    = highline.ask("SSH port:    ") { |q| q.default = "22" }
  conf.local_port  = highline.ask("Local port:  ") { |q| q.default = "3000" }
  conf.remote_user = highline.ask("Remote user: ") { |q| q.default = ENV['USER'] }
  conf.remote_host = highline.ask("Remote host: ")
  conf.remote_port = highline.ask("Remote port: ")

  Configfile.add(conf)
end

#listObject



19
20
21
22
23
# File 'lib/tunnel/cli.rb', line 19

def list
  configs.each_with_index do |c, i|
    puts "#{i+1}. #{c}"
  end
end

#startObject



8
9
10
11
12
13
14
15
16
# File 'lib/tunnel/cli.rb', line 8

def start
  highline = HighLine.new
  highline.choose do |menu|
    menu.choices(*configs) do |choice|
      choice.verbose = options.verbose?
      Tunnel.start(choice)
    end
  end
end