handle --help as any other option

earlier -h was recognized as a special case
in "argumentparser.rb"
This commit is contained in:
Johan Holmberg 2016-09-27 00:03:16 +02:00
parent e76dd95bcb
commit aa9d2c4f93
2 changed files with 8 additions and 8 deletions

View File

@ -572,6 +572,7 @@ module Cmdtest
def _parse_options
pr = @argument_parser = ArgumentParser.new("cmdtest")
pr.add("-h", "--help", "show this help message and exit")
pr.add("", "--version", "show version")
pr.add("-q", "--quiet", "be more quiet")
pr.add("-v", "--verbose", "be more verbose")
@ -585,7 +586,13 @@ module Cmdtest
pr.add("-i", "--incremental", "incremental mode")
pr.add("", "--slave", "run in slave mode", type: String)
pr.addpos("arg", "testfile or pattern", nargs: 0..999)
return pr.parse_args(ARGV, patterns: [], ruby_s: Util.windows?)
opts = pr.parse_args(ARGV, patterns: [], ruby_s: Util.windows?)
if opts.help
pr.print_usage()
exit(0)
end
return opts
end
def run

View File

@ -133,8 +133,6 @@ module Cmdtest
@help = false
@args = []
add("-h", "--help", "show this help message and exit")
end
def add(sname, name, help, args = {})
@ -206,11 +204,6 @@ module Cmdtest
@optind = 0
while _more_args() && _arg() =~ /^-./
if _arg() == "-h"
print_usage()
exit(0)
end
if _arg() == "--"
@optind += 1
break