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
- #dispatch(command) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
34 35 36 |
# File 'lib/procodile/cli.rb', line 34 def initialize @options = {} end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
32 33 34 |
# File 'lib/procodile/cli.rb', line 32 def config @config end |
#options ⇒ Object
Returns the value of attribute options.
31 32 33 |
# File 'lib/procodile/cli.rb', line 31 def @options end |
Class Method Details
.command(name) ⇒ Object
25 26 27 28 29 |
# File 'lib/procodile/cli.rb', line 25 def self.command(name) commands[name] = {:name => name, :description => @description, :options => @options} @description = nil @options = nil end |
.commands ⇒ Object
13 14 15 |
# File 'lib/procodile/cli.rb', line 13 def self.commands @commands ||= {} end |
.desc(description) ⇒ Object
17 18 19 |
# File 'lib/procodile/cli.rb', line 17 def self.desc(description) @description = description end |
.options(&block) ⇒ Object
21 22 23 |
# File 'lib/procodile/cli.rb', line 21 def self.(&block) @options = block end |
Instance Method Details
#dispatch(command) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/procodile/cli.rb', line 38 def dispatch(command) if self.class.commands.keys.include?(command.to_sym) public_send(command) else raise Error, "Invalid command '#{command}'" end end |