Method: Thor::Base::ClassMethods#start
- Defined in:
- lib/thor/base.rb
permalink #start(given_args = ARGV, config = {}) ⇒ Object
Parses the command and options from the given args, instantiate the class and invoke the command. 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, , config)
script.invoke(:command, first_arg, second_arg, third_arg)
582 583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/thor/base.rb', line 582 def start(given_args = ARGV, config = {}) config[:shell] ||= Thor::Base.shell.new dispatch(nil, given_args.dup, nil, config) rescue Thor::Error => e config[:debug] || ENV["THOR_DEBUG"] == "1" ? (raise e) : config[:shell].error(e.) exit(false) if exit_on_failure? rescue Errno::EPIPE # This happens if a thor command is piped to something like `head`, # which closes the pipe when it's done reading. This will also # mean that if the pipe is closed, further unnecessary # computation will not occur. exit(true) end |