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

Unlimited positional and unlimitied option #102

Closed
harrywong opened this issue Apr 10, 2018 · 1 comment · Fixed by #103
Closed

Unlimited positional and unlimitied option #102

harrywong opened this issue Apr 10, 2018 · 1 comment · Fixed by #103
Milestone

Comments

@harrywong
Copy link

harrywong commented Apr 10, 2018

Hi, have a question. I have a situation where there's one unlimited positional and one unlimited option. Like this:

std::vector<std::string> t1, t2;
app->add_option("test1", t1);
app->add_option("--test2", t2);

If you give these arguments: ./test a b c --test2 d e f, then a b c and e f will go to t1, and only d will go to t2.

I've seen in the source code:

// If there are any unlimited positionals, those also take priority

Could you please explain why you design like this? I think in this situation, d e f should go to t2.

@henryiii
Copy link
Collaborator

henryiii commented Apr 10, 2018

Originally, it was impossible to "end" an unlimited option for a positional since there was no way for a positional to start taking values. The idea was that this could be a workaround:

./test a b c --test2 d --test2 e --test2 f

However, the underlying problem was fixed in CLI11 1.5, you can now use -- to end an unlimited string of values to an option. So this "greedy positional" behavior could be removed (I might even consider this for a 1.5.1 release).

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

Successfully merging a pull request may close this issue.

2 participants