Class: Rspawn::CLI
- Inherits:
-
Thor
- Object
- Thor
- Rspawn::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/rspawn/cli.rb
Instance Method Summary collapse
-
#initialize(args = [], options = {}, config = {}) ⇒ CLI
constructor
A new instance of CLI.
- #restart(key) ⇒ Object
- #restart_all ⇒ Object
- #rm(key) ⇒ Object
- #start(key) ⇒ Object
- #status(key = nil) ⇒ Object
- #stop(key) ⇒ Object
- #tail(key) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ CLI
Returns a new instance of CLI.
17 18 19 20 21 |
# File 'lib/rspawn/cli.rb', line 17 def initialize(args = [], = {}, config = {}) super(args, , config) @class_options = config[:shell].base. @config = get_config(args.first) end |
Instance Method Details
#restart(key) ⇒ Object
31 32 33 |
# File 'lib/rspawn/cli.rb', line 31 def restart(key) start_action(['command'], 'restart') end |
#restart_all ⇒ Object
37 38 39 40 41 42 |
# File 'lib/rspawn/cli.rb', line 37 def restart_all get_keys.each do |key| option, command = get_config(key).option RspawnWorker.spawn!(option, ['restart', command]) end end |
#rm(key) ⇒ Object
65 66 67 |
# File 'lib/rspawn/cli.rb', line 65 def rm(key) @config.remove end |
#start(key) ⇒ Object
25 26 27 |
# File 'lib/rspawn/cli.rb', line 25 def start(key) start_action(['command'], 'start') end |
#status(key = nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rspawn/cli.rb', line 51 def status(key = nil) result = {} get_keys(key).each do |proc_name| option, command = get_config(proc_name).option option[:status] = capture_stdout do RspawnWorker.spawn!(option, ["status"]) end option[:command] = command result[proc_name] = option end puts JSON.pretty_generate(result) end |
#stop(key) ⇒ Object
45 46 47 48 |
# File 'lib/rspawn/cli.rb', line 45 def stop(key) option, command = @config.option RspawnWorker.spawn!(option, ["stop"]) end |
#tail(key) ⇒ Object
70 71 72 73 |
# File 'lib/rspawn/cli.rb', line 70 def tail(key) option, command = @config.option(nil) tail_log(option[:log_file]) end |
#version ⇒ Object
76 77 78 |
# File 'lib/rspawn/cli.rb', line 76 def version puts VERSION end |