-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
Problem Description
When I declare command line arguments as required
, they are required to be passed, as expected. However, the help text (viewed by passing --help
as a command line argument) still calls these arguments "optional". More precisely, it lists them after the headline "optional arguments:". Is this intended behavior or a bug?
Code example to reproduce
# Julia Version 1.6.2
# filename "./tmp/argparse_bug.jl" (used below)
using ArgParse
function parse_my_args(args)
s = ArgParseSettings("Program to look for ArgParse help display bug, which calls required parameters optional.")
@add_arg_table! s begin
"--required_argument"
arg_type = String
help = "Required string argument."
required = true
"--optional_value", "-o"
help = "Optional integer arument."
default = 1
arg_type = Int
end
parsed_args = parse_args(args, s)
println("Parsed args:")
for (key, val) in parsed_args
println(" $key => $(repr(val))")
end
return parsed_args["required_argument"], parsed_args["optional_value"]
end
function main(args)
output = parse_my_args(args)
@show output
end
main(ARGS)
to reproduce:
$ julia ./tmp/argparse_bug.jl --help
usage: argparse_bug.jl --required_argument REQUIRED_ARGUMENT
[-o OPTIONAL_VALUE] [-h]
Program to look for ArgParse help display bug, which calls required
parameters optional.
optional arguments:
--required_argument REQUIRED_ARGUMENT
Required string argument.
-o, --optional_value OPTIONAL_VALUE
Optional integer arument. (type: Int64,
default: 1)
-h, --help show this help message and exit
System information
ArgParse v1.1.4
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
DilumAluthge, stepanzh and newptcai
Metadata
Metadata
Assignees
Labels
No labels