Closed lahwaacz closed 2 years ago
This is related to https://github.com/bfgroup/Lyra/issues/24
GNU tools and many others use the --
argument as separator indicating that all following arguments are positionals rather than options. See e.g. grep example.
GNU tools and many others use the
--
argument as separator indicating that all following arguments are positionals rather than options. See e.g. grep example.
Right. There are two choices.. You do not treat "--xxx" as a special prefix that only means an option. Which is what Lyra does currently. Or you do make "--xxx" special and then need the special token, i.e. "--"by itself, to turn off the restriction. The only way for a CLI to support that would be have two different, mutually exclusive, parsing modes.
When there are options as well as positional arguments, some of which may be optional, there is a problem with unknown options. Consider this repro case:
which leads to this output:
This is a problem, because
--bar
as is not reported as unknown/invalid option, but passed to the next positional argument. It is pretty unlikely that the user intended to use--bar
as a positional argument -- most likely they made a typo or another mistake and need to read the help page.