module Canals::Cli::Helpers
Public Instance Methods
check_completion()
click to toggle source
# File lib/canals/cli/helpers.rb, line 55 def check_completion if Canals.config[:completion_version] if Canals.config[:completion_version] != Canals::VERSION Canals::Tools::Completion.update_completion say "Bash completion script upgraded, use `source #{Canals::Tools::Completion.cmp_file}` to reload it", :red end end end
checkmark(bool)
click to toggle source
transform boolean into ✓ / ✗
# File lib/canals/cli/helpers.rb, line 65 def checkmark(bool) bool ? "\u2713".encode('utf-8') : "\u2717".encode('utf-8') end
startup_checks()
click to toggle source
# File lib/canals/cli/helpers.rb, line 51 def startup_checks check_completion end
trestart(tunnel_opts)
click to toggle source
# File lib/canals/cli/helpers.rb, line 33 def trestart(tunnel_opts) if tunnel_opts.instance_of? String tunnel_opts = tunnel_options(tunnel_opts) end tstop(tunnel_opts) tstart(tunnel_opts) end
tstart(tunnel_opts, silent: false)
click to toggle source
# File lib/canals/cli/helpers.rb, line 17 def tstart(tunnel_opts, silent: false) if tunnel_opts.instance_of? String tunnel_opts = tunnel_options(tunnel_opts) end pid = Canals.start(tunnel_opts) say "Created tunnel #{tunnel_opts.name.inspect} with pid #{pid}. You can access it using '#{tunnel_opts.bind_address}:#{tunnel_opts.local_port}'" unless silent pid rescue Canals::Exception => e if tunnel_opts.instance_of? String tunnel_opts = tunnel_options(tunnel_opts) end isalive = Canals.isalive? tunnel_opts say "Unable to create tunnel #{tunnel_opts.name.inspect}#{isalive ? ', A tunnel for ' + tunnel_opts.name.inspect + ' Already exists.' : ''}", :red 0 end
tstop(tunnel_opts, remove_from_session: true, silent: false)
click to toggle source
# File lib/canals/cli/helpers.rb, line 9 def tstop(tunnel_opts, remove_from_session: true, silent: false) if tunnel_opts.instance_of? String tunnel_opts = tunnel_options(tunnel_opts) end Canals.stop(tunnel_opts, remove_from_session: remove_from_session) say "Tunnel #{tunnel_opts.name.inspect} stopped." unless silent end
tunnel_options(name)
click to toggle source
# File lib/canals/cli/helpers.rb, line 41 def tunnel_options(name) if (Canals.session.has?(name)) Canals.session.get_obj(name) elsif (Canals.repository.has?(name)) Canals.repository.get(name) else raise Thor::Error.new "Unable to find tunnel #{name.inspect}." end end