Class: Procodile::CLI
- Inherits:
-
Object
- Object
- Procodile::CLI
- Defined in:
- lib/procodile/cli.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run(command) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
32 33 34 |
# File 'lib/procodile/cli.rb', line 32 def initialize = {} end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
30 31 32 |
# File 'lib/procodile/cli.rb', line 30 def config @config end |
#options ⇒ Object
Returns the value of attribute options.
29 30 31 |
# File 'lib/procodile/cli.rb', line 29 def end |
Class Method Details
.command(name) ⇒ Object
23 24 25 26 27 |
# File 'lib/procodile/cli.rb', line 23 def self.command(name) commands[name] = {:name => name, :description => @description, :options => } @description = nil = nil end |
.commands ⇒ Object
11 12 13 |
# File 'lib/procodile/cli.rb', line 11 def self.commands @commands ||= {} end |
.desc(description) ⇒ Object
15 16 17 |
# File 'lib/procodile/cli.rb', line 15 def self.desc(description) @description = description end |
.options(&block) ⇒ Object
19 20 21 |
# File 'lib/procodile/cli.rb', line 19 def self.(&block) = block end |
Instance Method Details
#run(command) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/procodile/cli.rb', line 36 def run(command) if self.class.commands.keys.include?(command.to_sym) public_send(command) else raise Error, "Invalid command '#{command}'" end end |