Module: Bosh::Cli::CommandDiscovery
- Included in:
- Bosh::Cli::Command::Base
- Defined in:
- lib/cli/command_discovery.rb
Instance Method Summary collapse
- #desc(string) ⇒ Object
- #method_added(method_name) ⇒ Object
- #option(name, *args) ⇒ Object
- #register_command(method, usage, desc, options = []) ⇒ Object
- #usage(string = nil) ⇒ Object
Instance Method Details
#desc(string) ⇒ Object
10 11 12 |
# File 'lib/cli/command_discovery.rb', line 10 def desc(string) @desc = string end |
#method_added(method_name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cli/command_discovery.rb', line 19 def method_added(method_name) if @usage && @desc @options ||= [] method = instance_method(method_name) register_command(method, @usage, @desc, @options) end @usage = nil @desc = nil @options = [] end |
#option(name, *args) ⇒ Object
14 15 16 |
# File 'lib/cli/command_discovery.rb', line 14 def option(name, *args) (@options ||= []) << [name, args] end |
#register_command(method, usage, desc, options = []) ⇒ Object
34 35 36 37 |
# File 'lib/cli/command_discovery.rb', line 34 def register_command(method, usage, desc, = []) command = CommandHandler.new(self, method, usage, desc, ) Bosh::Cli::Config.register_command(command) end |
#usage(string = nil) ⇒ Object
6 7 8 |
# File 'lib/cli/command_discovery.rb', line 6 def usage(string = nil) @usage = string end |