Open adomasbaliuka opened 3 years ago
It's not exactly intended behavior. I wouldn't know how to call them though. This is one of the reasons why I disliked this feature. By the way, this is also the same behavior found in Python's argparse:
In [1]: import argparse
In [2]: parser = argparse.ArgumentParser()
In [3]: parser.add_argument('--foo', required = True)
Out[3]: _StoreAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, default=None, type=None, choices=None, help=None, metavar=None)
In [4]: parser.parse_args(['-h'])
usage: ipykernel_launcher.py [-h] --foo FOO
optional arguments:
-h, --help show this help message and exit
--foo FOO
I wouldn't know how to fix this exactly. I guess that it would make sense to change the name "optional arguments" to something else, considered they may not be optional. Maybe "named arguments", in contrast to "positional arguments"? But "optional arguments" is how people refers to them since forever, I think.
Any suggestions?
By the way, right now you can always create a new separate group, e.g.:
julia> s = ArgParseSettings();
julia> add_arg_group!(s, "required arguments", "REQ");
julia> @add_arg_table! s begin
"--req"
required = true
group = "REQ"
"--opt"
group = "optional"
end
julia> parse_args(["-h"], s)
usage: <PROGRAM> --req REQ [--opt OPT] [-h]
optional arguments:
--opt OPT
-h, --help show this help message and exit
required arguments:
--req REQ
Perhaps of the semantic ambiguity, clig.dev define CLI arguments as "args" and "flags" https://clig.dev/#arguments-and-flags.
Suggestion: Have an option to list user-created argument groups above the "optional"
default group? At first I thought they were listed alphabetically but the optional group is always displayed first (at the top).
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
to reproduce:
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)