Module: Clin::CommandMixin::Dispatcher::ClassMethods
- Defined in:
- lib/clin/command_mixin/dispatcher.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#_redispatch_args ⇒ Object
Returns the value of attribute _redispatch_args.
Instance Method Summary collapse
-
#dispatch(args, prefix: nil, commands: nil) ⇒ Object
Redispatch the command to a sub command with the given arguments If no commands are given it will look for Clin::Command in the class namespace e.g.
- #dispatch_doc(opts) ⇒ Object
- #redispatch? ⇒ Boolean
Instance Attribute Details
#_redispatch_args ⇒ Object
Returns the value of attribute _redispatch_args.
7 8 9 |
# File 'lib/clin/command_mixin/dispatcher.rb', line 7 def _redispatch_args @_redispatch_args end |
Instance Method Details
#dispatch(args, prefix: nil, commands: nil) ⇒ Object
Redispatch the command to a sub command with the given arguments If no commands are given it will look for Clin::Command in the class namespace e.g. If those 2 classes are defined. ‘MyDispatcher < Clin::Command` and `MyDispatcher::ChildCommand < Clin::Command` Will test against ChildCommand
17 18 19 |
# File 'lib/clin/command_mixin/dispatcher.rb', line 17 def dispatch(args, prefix: nil, commands: nil) @_redispatch_args = [[*args], prefix, commands] end |
#dispatch_doc(opts) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/clin/command_mixin/dispatcher.rb', line 25 def dispatch_doc(opts) return if _redispatch_args.nil? opts.separator 'Examples: ' commands = (_redispatch_args[2] || default_commands) commands.each do |cmd_cls| opts.separator "\t#{cmd_cls.usage}" end end |
#redispatch? ⇒ Boolean
21 22 23 |
# File 'lib/clin/command_mixin/dispatcher.rb', line 21 def redispatch? !@_redispatch_args.nil? end |