how to define single repeatable joinable option
risa2000 opened this issue · comments
I am trying to figure out, how to implement an option for a "verbosity" level -v
. The idea is that it should be repeatable and joinable, i.e. -v
should set it to 1, -vvv
should set it to 3.
I have found an example for repeatable and joinable options:
auto cli = joinable(
repeatable(
option("a")([&]{++as;}) |
option("b")([&]{++bs;})
)
);
which works fine. But when I try to define my option:
auto verb = 0;
bool d = false;
auto cli = (<...>,
joinable(repeatable(option("-v").call(increment(verb)) % verb_help))
// joinable(repeatable(option("-v").call(increment(verb)) % verb_help, option("-d").set(d)))
);
the parsing fails on anything different from -v
. What I found that it starts working as expected when I add "dummy" option -d
to the joinable and repeatable list.
Yeah this is a bug. I guess I just never though of having only one joinable option on its own.
I'll fix it, but I don't know how soon I can get to it.
This "just works" with:
joinable(option("-v","--verbose").repeatable(true).doc("increase verbosity"))