module Thor::Base
def self.shell
Returns the shell used in all Thor classes. Default to color one.
def self.shell @shell ||= Thor::Shell::Color end
def self.shell=(klass)
Sets the shell used in all Thor classes.
def self.shell=(klass) @shell = klass end
def included(base) #:nodoc:
def included(base) #:nodoc: base.send :extend, ClassMethods base.send :include, Invocation base.send :include, Shell end
def initialize(args=[], options={}, config={})
config
access, magic predicates (options.skip?) and then frozen.
The hash given is converted to a hash with indifferent
options
respective accessors declared with argument.
args
==== Parameters
It should be done by the parser.
Notice that it does not check if all required arguments were supplied.
other for configuration.
It receives arguments in an Array and two hashes, one for options and
def initialize(args=[], options={}, config={}) Thor::Arguments.parse(self.class.arguments, args).each do |key, value| send("#{key}=", value) end parse_options = self.class.class_options if options.is_a?(Array) task_options = config.delete(:task_options) # hook for start parse_options = parse_options.merge(task_options) if task_options array_options, hash_options = options, {} else array_options, hash_options = [], options end options = Thor::Options.parse(parse_options, array_options) self.options = Thor::CoreExt::HashWithIndifferentAccess.new(options).merge!(hash_options) self.options.freeze end
def register_klass_file(klass) #:nodoc:
class and the file on Thor::Base. This is the method responsable for it.
Whenever a class inherits from Thor or Thor::Group, we should track the
def register_klass_file(klass) #:nodoc: file = caller[1].match(/(.*):\d+/)[1] Thor::Base.subclasses << klass unless Thor::Base.subclasses.include?(klass) file_subclasses = Thor::Base.subclass_files[File.expand_path(file)] file_subclasses << klass unless file_subclasses.include?(klass) end
def subclass_files
Hash[path
==== Returns
Returns the files where the subclasses are kept.
def subclass_files @subclass_files ||= Hash.new{ |h,k| h[k] = [] } end
def subclasses
Array[Class]
==== Returns
Returns the classes that inherits from Thor or Thor::Group.
def subclasses @subclasses ||= [] end