Module: Canals::Cli::Helpers

Included in:
Application, Session
Defined in:
lib/canals/cli/helpers.rb

Instance Method Summary collapse

Instance Method Details

#check_completionObject



30
31
32
33
34
35
36
37
# File 'lib/canals/cli/helpers.rb', line 30

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) ⇒ Object

transform boolean into ✓ / ✗



40
41
42
# File 'lib/canals/cli/helpers.rb', line 40

def checkmark(bool)
  bool ? "\u2713".encode('utf-8') : "\u2717".encode('utf-8')
end

#startup_checksObject



26
27
28
# File 'lib/canals/cli/helpers.rb', line 26

def startup_checks
  check_completion
end

#trestart(name) ⇒ Object



21
22
23
24
# File 'lib/canals/cli/helpers.rb', line 21

def trestart(name)
  tstop(name)
  tstart(name)
end

#tstart(name) ⇒ Object



14
15
16
17
18
19
# File 'lib/canals/cli/helpers.rb', line 14

def tstart(name)
  pid = Canals.start(name)
  tunnel = Canals.repository.get(name)
  say "Created tunnel #{name.inspect} with pid #{pid}. You can access it using '#{tunnel.bind_address}:#{tunnel.local_port}'"
  pid
end

#tstop(name) ⇒ Object



9
10
11
12
# File 'lib/canals/cli/helpers.rb', line 9

def tstop(name)
  Canals.stop(name)
  say "Tunnel #{name.inspect} stopped."
end