Class: Thor::DynamicCommand
- Defined in:
- lib/thor/command.rb
Overview
A dynamic command that handles method missing scenarios.
Constant Summary
Constants inherited from Command
Instance Attribute Summary
Attributes inherited from Command
#ancestor_name, #description, #long_description, #name, #options, #options_relation, #usage, #wrap_long_description
Instance Method Summary collapse
-
#initialize(name, options = nil) ⇒ DynamicCommand
constructor
A new instance of DynamicCommand.
- #run(instance, args = []) ⇒ Object
Methods inherited from Command
#formatted_usage, #hidden?, #initialize_copy, #method_at_least_one_option_names, #method_exclusive_option_names
Constructor Details
#initialize(name, options = nil) ⇒ DynamicCommand
Returns a new instance of DynamicCommand.
138 139 140 |
# File 'lib/thor/command.rb', line 138 def initialize(name, = nil) super(name.to_s, "A dynamically-generated command", name.to_s, nil, name.to_s, ) end |
Instance Method Details
#run(instance, args = []) ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/thor/command.rb', line 142 def run(instance, args = []) if (instance.methods & [name.to_s, name.to_sym]).empty? super else instance.class.handle_no_command_error(name) end end |