-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionals that are somewhat positional #712
Comments
You likely want to look at |
Thanks for the swift reply! I can now get case 2 working. However, case 1 still doesn't work: callback for positional is invoked after parsing still. Full test program attached below:
Compile and run:
I would expect
|
By the way, the conan center still only has version 1.9.1: https://conan.io/center/CLI11 Edit: never mind, found https://conan.io/center/cli11 |
I think this is issue is resolved in the latest release now that trigger_on_parse works for positional arguments as well |
Behavior 1
In gcc there is an option
-x <language>
that works as described:This means that while
-x
looks like an optional, it is positional and affect the following positionals:is different from
Behavior 2
Furthermore, there are flags in the gcc/linker that affect the following options. Take
--whole-archive
:The above basically turns on
whole-archive
formylib1
, but notmylib2
.Question
Is there a way to emulate the above behaviors with CLI11?
Notes
I've searched to docs through and through and haven't found a good answer.
With behavior 1, I can somewhat get around with
Only 2 issues: no separate help messages for
file
and-x
; one can't really tell whether an element inargs
is contributed by-x
orfile
.With behavior 2, there isn't much I can do about it.
Just my opinion: it would solve both cases if
add_option
andadd_flag
accept a callback that is invoked for each individual argument during the parsing stage. Something like:The text was updated successfully, but these errors were encountered: