Class: Explorer::CLI::Process
- Inherits:
-
Thor
- Object
- Thor
- Explorer::CLI::Process
- Defined in:
- lib/explorer/cli/process.rb
Instance Method Summary collapse
- #add(label, cmd) ⇒ Object
- #list ⇒ Object
- #remove(label) ⇒ Object
- #start(label) ⇒ Object
- #stop(label) ⇒ Object
- #tail ⇒ Object
Instance Method Details
#add(label, cmd) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/explorer/cli/process.rb', line 20 def add(label, cmd) Celluloid.logger = nil # Silence celluloid ipc = IPCClient.new ipc.cmd_add(label, cmd, [:dir]) puts Rainbow("Added #{label}").color(:green).bright rescue Errno::ENOENT puts Rainbow('Explore is not running').color(:red).bright end |
#list ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/explorer/cli/process.rb', line 64 def list Celluloid.logger = nil # Silence celluloid ipc = IPCClient.new list = ipc.cmd_list data = list.map do |p| color = if p['state'] == 'stopped' 'red' else 'green' end { label: "[#{color}]#{p['label']}[/]", command: "[#{color}]#{p['cmd']}[/]", 'working directory' => "[#{color}]#{p['dir']}[/]", 'PID' => "[#{color}]#{p['pid']}[/]", 'exit code' => "[#{color}]#{p['status']}[/]", 'status' => "[#{color}]#{p['state']}[/]", } end Formatador.display_compact_table(data, [:label, :command, 'PID', 'exit code', 'status', 'working directory']) rescue Errno::ENOENT puts Rainbow('Explore is not running').color(:red).bright end |
#remove(label) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/explorer/cli/process.rb', line 53 def remove(label) Celluloid.logger = nil # Silence celluloid ipc = IPCClient.new ipc.cmd_remove(label) puts Rainbow("Removed #{label}").color(:green).bright rescue Errno::ENOENT puts Rainbow('Explore is not running').color(:red).bright end |
#start(label) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/explorer/cli/process.rb', line 31 def start(label) Celluloid.logger = nil # Silence celluloid ipc = IPCClient.new ipc.cmd_start(label) puts Rainbow("Started #{label}").color(:green).bright rescue Errno::ENOENT puts Rainbow('Explore is not running').color(:red).bright end |
#stop(label) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/explorer/cli/process.rb', line 42 def stop(label) Celluloid.logger = nil # Silence celluloid ipc = IPCClient.new ipc.cmd_stop(label) puts Rainbow("Stopped #{label}").color(:green).bright rescue Errno::ENOENT puts Rainbow('Explore is not running').color(:red).bright end |