Closed elegracer closed 1 year ago
This example seems to create an empty group, not containing anything, so it doesn't really work even if it compiles. But I don't see how can you use lyra::group()
with the operator syntax neither, which is a pity because I prefer the more compact syntax, but it appears to be incompatible with something as simple as the standard --version
option, as specifying it must make all the other options optional, which can only be achieved by using a group in Lyra, AFAICS.
I'd really like to know how to implement --version
handling with Lyra in a simple way.
I just want to use lyra::group
with operator syntax, but can't find an example.
Yes, me too. I don't think it's possible right now because operator|
only works with cli
objects that are not convertible to arguments
(it uses non-public inheritance) and so can't be consumed by a group
. But I could be wrong...
@elegracer like @vadz said you are creating an empty group. I think you meant to make --id and --grade part of the group. I created a test case for your example (and others) here https://github.com/bfgroup/Lyra/blob/develop/tests/issue_65_run_test.cpp#L128 that shows things working.
@vadz there are a couple of ways to implement a --version type argument. The most obvious one is to make it work like the help which uses a short circuit to ignore anything else https://github.com/bfgroup/Lyra/blob/develop/include/lyra/help.hpp#L32. Also I made a related fix on another issue which I think also resolved what you experienced with the op| and group. I added test cases to check for that to the test for this issue https://github.com/bfgroup/Lyra/blob/develop/tests/issue_65_run_test.cpp#L78.
For lyra::group, I'd like to use the "|" operator chain way, but no example in the docs, and it seems that the callback passed into lyra::group isn't called.
Am I using it wrong? or is it a bug?
Thanks!