Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Accept a debug config in the start method

This will make easier to start a debug environment per action.
  • Loading branch information...
commit 72f2071cdf73f02be939224a4c17c07f58f106ff 1 parent ed0f1c1
@rafaelfranca rafaelfranca authored
Showing with 7 additions and 1 deletion.
  1. +1 −1  lib/thor/base.rb
  2. +6 −0 spec/base_spec.rb
View
2  lib/thor/base.rb
@@ -439,7 +439,7 @@ def start(given_args = ARGV, config = {})
config[:shell] ||= Thor::Base.shell.new
dispatch(nil, given_args.dup, nil, config)
rescue Thor::Error => e
- ENV['THOR_DEBUG'] == '1' ? (raise e) : config[:shell].error(e.message)
+ config[:debug] || ENV['THOR_DEBUG'] == '1' ? (raise e) : config[:shell].error(e.message)
exit(1) if exit_on_failure?
rescue Errno::EPIPE
# This happens if a thor command is piped to something like `head`,
View
6 spec/base_spec.rb
@@ -256,6 +256,12 @@ def hello
end
end
+ it 'raises an error instead of rescuing if :debug option is given' do
+ expect do
+ MyScript.start %w[what], :debug => true
+ end.to raise_error(Thor::UndefinedCommandError, 'Could not find command "what" in "my_script" namespace.')
+ end
+
it 'does not steal args' do
args = %w[foo bar --force true]
MyScript.start(args)
Please sign in to comment.
Something went wrong with that request. Please try again.