Class: Canals::Cli::Application
- Inherits:
-
Thor
- Object
- Thor
- Canals::Cli::Application
show all
- Includes:
- Helpers, Thor::Actions
- Defined in:
- lib/canals/cli.rb
Instance Method Summary
collapse
Methods included from Helpers
#check_completion, #startup_checks, #trestart, #tstart, #tstop
Constructor Details
Returns a new instance of Application.
18
19
20
21
|
# File 'lib/canals/cli.rb', line 18
def initialize(*args)
super
startup_checks
end
|
Instance Method Details
#create(name, remote_host, remote_port, local_port = nil) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/canals/cli.rb', line 27
def create(name, remote_host, remote_port, local_port=nil)
opts = {"name" => name, "remote_host" => remote_host, "remote_port" => remote_port, "local_port" => local_port}.merge(options)
opts = Canals::CanalOptions.new(opts)
Canals.create_tunnel(opts)
say "Tunnel #{name.inspect} created.", :green
end
|
#repo ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/canals/cli.rb', line 53
def repo
if Canals.repository.empty?
say "Repository is currently empty."
return
end
require 'terminal-table'
require 'canals/core_ext/string'
columns = ["name", "remote_host", "remote_port", "local_port"]
columns_extra = ["bind_address", "env_name", "user", "hostname"]
if options[:full]
columns += columns_extra
end
env = options[:env]
sort_by = options[:'sort-by'].downcase.split.join("_").to_sym
rows = Canals.repository.select { |conf| env.nil? || conf.env_name == env }
.sort { |a,b| a.send(sort_by) <=> b.send(sort_by) rescue a.name <=> b.name }
.map { |conf| columns.map{ |c| conf.send c.to_sym } }
table = Terminal::Table.new :headings => columns.map{|c| c.sub("_"," ").titleize }, :rows => rows
say table
say "* use --full to show more data", [:white, :dim] if !options[:full]
end
|
#restart(name) ⇒ Object
45
46
47
|
# File 'lib/canals/cli.rb', line 45
def restart(name)
trestart(name)
end
|
#start(name) ⇒ Object
35
36
37
|
# File 'lib/canals/cli.rb', line 35
def start(name)
tstart(name)
end
|
#stop(name) ⇒ Object
40
41
42
|
# File 'lib/canals/cli.rb', line 40
def stop(name)
tstop(name)
end
|