Class: Titan::CLI
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #status ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 |
# File 'lib/titan/cli.rb', line 7 def initialize(*) super @shell = Thor::Shell::Basic.new end |
Instance Method Details
#help ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/titan/cli.rb', line 13 def help @shell.say "The following methods are available through typing `titan method_name`" @shell.say "" available_methods = [ ["method_name", "description"], ["", ""], ["help", "Prints this page and describes available methods"], ["status", "Prints the status of all threads managed by Titan"], ["version", "Prints the currently installed version"] ] @shell.print_table(available_methods) end |
#status ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/titan/cli.rb', line 27 def status table_header = ["id", "pid", "status"] threads = Titan::Thread.all.each_value.collect do |thread| [thread.id.to_s, thread.pid.to_s, thread.alive? ? "alive" : "dead"] end @shell.print_table(threads.unshift(table_header)) unless threads.empty? end |