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, #arguments, #description, #examples, #long_description, #name, #options, #usage
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, #handle_argument_error?, #handle_no_method_error?, #hidden?, #initialize_copy, #local_method?, #names_by_format, #not_debugging?, #private_method?, #public_method?, #required_options, #sans_backtrace, #subcommand?, #usage_name
Constructor Details
#initialize(name, options = nil) ⇒ DynamicCommand
Returns a new instance of DynamicCommand.
362 363 364 365 366 367 368 |
# File 'lib/thor/command.rb', line 362 def initialize(name, = nil) super( name: name.to_s, description: "A dynamically-generated command", long_description: name.to_s, # why?! usage: name.to_s, options: ) end |
Instance Method Details
#run(instance, args = []) ⇒ Object
370 371 372 373 374 375 376 |
# File 'lib/thor/command.rb', line 370 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 |