Method: Thor::Base::ClassMethods#start

Defined in:
lib/thor/base.rb

- (Object) start(given_args = ARGV, config = {})

Parses the task and options from the given args, instantiate the class and invoke the task. This method is used when the arguments must be parsed from an array. If you are inside Ruby and want to use a Thor class, you can simply initialize it:

script = MyScript.new(args, options, config)
script.invoke(:task, first_arg, second_arg, third_arg)


386
387
388
389
390
391
392
393
# File 'lib/thor/base.rb', line 386

def start(given_args=ARGV, config={})
  self.debugging = given_args.delete("--debug")
  config[:shell] ||= Thor::Base.shell.new
  dispatch(nil, given_args.dup, nil, config)
rescue Thor::Error => e
  debugging ? (raise e) : config[:shell].error(e.message)
  exit(1) if exit_on_failure?
end

Comments