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, #startup_checks, #trestart, #tstart, #tstop

Instance Method Details

#restartObject



36
37
38
39
40
# File 'lib/canals/cli/session.rb', line 36

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

#restoreObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/canals/cli/session.rb', line 24

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

#showObject



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

def show
  return if session_empty?
  require 'terminal-table'
  require 'canals/core_ext/string'
  columns = ["pid", "name", "local_port", "socket"]
  rows = Canals.session.map{ |s| columns.map{ |c| s[c.to_sym] || get_session_col_val(s, c) } }
  table = Terminal::Table.new :headings => columns.map{|c| c.sub("_"," ").titleize }, :rows => rows
  say table
end

#stopObject



43
44
45
46
47
# File 'lib/canals/cli/session.rb', line 43

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