Class: Thor::DynamicCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/thor/command.rb

Overview

A dynamic command that handles method missing scenarios.

Constant Summary

Constants inherited from Command

Command::FILE_REGEXP

Instance Attribute Summary

Attributes inherited from Command

#ancestor_name, #description, #long_description, #name, #options, #usage

Instance Method Summary collapse

Methods inherited from Command

#formatted_usage, #handle_argument_error?, #handle_no_method_error?, #hidden?, #initialize_copy, #local_method?, #not_debugging?, #private_method?, #public_method?, #required_options, #sans_backtrace

Constructor Details

#initialize(name, options = nil) ⇒ DynamicCommand



183
184
185
186
187
188
189
# File 'lib/thor/command.rb', line 183

def initialize(name, options = nil)
  super(  name.to_s,
          "A dynamically-generated command",
          name.to_s,
          name.to_s,
          options )
end

Instance Method Details

#run(instance, args = []) ⇒ Object



191
192
193
194
195
196
197
# File 'lib/thor/command.rb', line 191

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