Class: Explorer::CLI::Proxy

Inherits:
Thor
  • Object
show all
Defined in:
lib/explorer/cli/proxy.rb

Instance Method Summary collapse

Instance Method Details

#add(domain, host, port) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/explorer/cli/proxy.rb', line 26

def add(domain, host, port)
  Celluloid.logger = nil # Silence celluloid

  ipc = IPCClient.new
  ipc.hostmap_add(domain, host, port)
  puts "Added #{domain} to proxy"
rescue Errno::ENOENT
  puts Rainbow('Explore is not running').color(:red).bright
end

#listObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/explorer/cli/proxy.rb', line 9

def list
  Celluloid.logger = nil # Silence celluloid

  ipc = IPCClient.new
  data = ipc.hostmap_list.map do |k, v|
    {
      domain: "[yellow]#{k}[/]",
      host: "[yellow]#{v['host']}[/]",
      port: "[yellow]#{v['port']}[/]",
    }
  end
  Formatador.display_compact_table(data, [:domain, :host, :port])
rescue Errno::ENOENT
  puts Rainbow('Explore is not running').color(:red).bright
end

#remove(domain) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/explorer/cli/proxy.rb', line 37

def remove(domain)
  Celluloid.logger = nil # Silence celluloid

  ipc = IPCClient.new
  ipc.hostmap_remove(domain)
  puts "Removed #{domain} from proxy"
rescue Errno::ENOENT
  puts Rainbow('Explore is not running').color(:red).bright
end