You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ ./main input-file compress
Unknown command: input-file
./main COMMAND {OPTIONS} input
Compress and decompress leveldb DB
OPTIONS:
-h, --help Display this help menu
input Input database file
commands
compress Enables compression on a database
decompress Remove compression on a database
"--" can be used to terminate flag options and force all following
arguments to be treated as positional options
Not like this, but the command is recognized
$ ./main compress input-file
Passed in argument, but no positional arguments were ready to receive it: input-file
./main compress
Enables compression on a database
OPTIONS:
And finally only with the command, the input field is still being requested.
$ ./main compress
terminate called after throwing an instance of 'args::RequiredError'
what(): Option 'input' is required
Aborted (core dumped)
The text was updated successfully, but these errors were encountered:
Unfortunately, commands are always sorted before all positionals at this point. They're really designed with the assumption that they will be the only expected positional for that parser, though the command underneath them can contain its own positionals.
I think I consider this a bug, but the way that commands are designed makes it a lot of effort to fix this bug, and I probably won't be able to get to it for quite some time. I'd recommend either re-ordering them to put any positionals after commands (ideally in a command callable with a subparser), using a MapFlag to choose your operation instead of a command, or taking your input argument via a flag. It's not a perfect answer, unfortunately. Personally, I'd probably use a MapFlag.
I'm trying to add a required positional before a group of commands but the parsing isn't working correctly. Here's an example:
It should work like this:
Not like this, but the command is recognized
And finally only with the command, the input field is still being requested.
The text was updated successfully, but these errors were encountered: