remove backtrace from stderr for unknown CLI options - close #69
This commit is contained in:
parent
6180410cc4
commit
ba69f05e99
@ -43,6 +43,18 @@ module Rscons
|
||||
# @return [void]
|
||||
def run(argv)
|
||||
argv = argv.dup
|
||||
begin
|
||||
exit run_toplevel(argv)
|
||||
rescue OptionParser::InvalidOption => io
|
||||
$stderr.puts io.message
|
||||
$stderr.puts USAGE
|
||||
exit 2
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def run_toplevel(argv)
|
||||
rsconscript = nil
|
||||
do_help = false
|
||||
|
||||
@ -115,8 +127,6 @@ module Rscons
|
||||
exit Rscons.application.run(operation, script, operation_options)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse_operation_args(operation, argv)
|
||||
case operation
|
||||
when "configure"
|
||||
|
@ -1531,6 +1531,24 @@ EOF
|
||||
expect(result.stderr).to match /Unknown operation: unknownop/
|
||||
expect(result.status).to_not eq 0
|
||||
end
|
||||
|
||||
it "displays usage and error message without a backtrace for an invalid CLI option" do
|
||||
test_dir "simple"
|
||||
result = run_rscons(rscons_args: %w[--xyz])
|
||||
expect(result.stderr).to_not match /Traceback/
|
||||
expect(result.stderr).to match /invalid option.*--xyz/
|
||||
expect(result.stderr).to match /Usage:/
|
||||
expect(result.status).to_not eq 0
|
||||
end
|
||||
|
||||
it "displays usage and error message without a backtrace for an invalid CLI option to a valid subcommand" do
|
||||
test_dir "simple"
|
||||
result = run_rscons(op: %w[configure --xyz])
|
||||
expect(result.stderr).to_not match /Traceback/
|
||||
expect(result.stderr).to match /invalid option.*--xyz/
|
||||
expect(result.stderr).to match /Usage:/
|
||||
expect(result.status).to_not eq 0
|
||||
end
|
||||
end
|
||||
|
||||
context "configure" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user