Class: Canals::Cli::Session

Inherits:
Thor
  • Object
show all
Includes:
Helpers, Thor::Actions
Defined in:
lib/canals/cli/session.rb

Instance Method Summary collapse

Methods included from Helpers

#check_completion, #checkmark, #startup_checks, #trestart, #tstart, #tstop, #tunnel_options

Instance Method Details

#restartObject



39
40
41
42
43
# File 'lib/canals/cli/session.rb', line 39

def restart
  on_all_canals_in_session(:restart) do |canal|
    trestart(canal)
  end
end

#restoreObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/canals/cli/session.rb', line 27

def restore
  on_all_canals_in_session(:restore) do |canal|
    if Canals.isalive? canal
      say "Canal #{canal.name.inspect} is running."
    else
      Canals.session.del(canal.name)
      tstart(canal)
    end
  end
end

#showObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/canals/cli/session.rb', line 14

def show
  return if session_empty?
  require 'terminal-table'
  require 'canals/core_ext/string'
  columns = ["up", "pid", "name", "local_port", "socket"]
  rows = Canals.session.sort{ |a,b| a[:name] <=> b[:name] }
                       .map { |s| columns.map{ |c| session_col_val(s, c) } }
  table = Terminal::Table.new :headings => columns.map{|c| session_col_title(c) }, :rows => rows
  table.align_column(3, :right)
  say table
end

#stopObject



46
47
48
49
50
# File 'lib/canals/cli/session.rb', line 46

def stop
  on_all_canals_in_session(:stop) do |canal|
    tstop(canal)
  end
end

#suspendObject



53
54
55
56
57
# File 'lib/canals/cli/session.rb', line 53

def suspend
  on_all_canals_in_session(:suspend) do |canal|
    tstop(canal, remove_from_session: false)
  end
end