lib/canals/cli/session.rb in canals-0.8.1 vs lib/canals/cli/session.rb in canals-0.8.2
- old
+ new
@@ -12,12 +12,12 @@
desc "show", "Show the current session"
def show
return if session_empty?
require 'terminal-table'
require 'canals/core_ext/string'
- columns = ["pid", "name", "socket"]
- rows = Canals.session.map{ |s| columns.map{ |c| s[c.to_sym] } }
+ 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
desc "restore", "Restore the connection to tunnels which aren't working"
@@ -53,9 +53,18 @@
say "#{command.to_s.capitalize} canal #{name.inspect}:", :green
block.call(name)
end
say
say "#{command} done.", :green
+ end
+
+ def get_session_col_val(session, key)
+ case key
+ when "local_port"
+ entry = Canals.repository.get(session[:name])
+ return entry.local_port if entry
+ end
+ nil
end
def session_empty?
if Canals.session.empty?
say "Canal session is currently empty."