(Go: >> BACK << -|- >> HOME <<)

Skip to content
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

how to define single repeatable joinable option #28

Open
risa2000 opened this issue Jun 20, 2019 · 2 comments
Open

how to define single repeatable joinable option #28

risa2000 opened this issue Jun 20, 2019 · 2 comments
Labels

Comments

@risa2000
Copy link

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.

@muellan muellan added the bug label Jun 24, 2019
@muellan
Copy link
Owner
muellan commented Jun 24, 2019

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.

@afranchuk
Copy link

This "just works" with:

joinable(option("-v","--verbose").repeatable(true).doc("increase verbosity"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants