-
Notifications
You must be signed in to change notification settings - Fork 574
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
Positional arguments #15
Comments
This sounds pretty reasonable. Are you suggesting that you would be able to make the changes? Just so I understand, you want to link positional arguments to different named arguments? At the moment I think it just puts everything into one positional argument. So in the above example, parsing the first positional argument lets me get it as I'm not sure what you mean by eating the remaining arguments. Do you mean that if one of the positional arguments takes a vector then it just gets all the rest of the positional arguments? |
On 10/09/15 06:38, jarro2783 wrote:
I would be, though not now. I was looking at the code too see if this
Yes.
Right. It's pretty common for me to have: $ cmd [flags] cmd file [file ...] With the above, if you link "file" to vector, you effectively Granted, you can do the same without, but I think it would be a nice touch. |
I don't think it's hard. I'm not really in a position to do it right now either. We can leave this issue open and someone can do it eventually. Let us know if you feel like doing it before I do. |
I'm working on this now. |
This is done now. |
It would be nice to improve a bit the handling of positional arguments to be
more unix-y. A practical example of what I'd have in mind:
Where:
Options::parse
is a list of positional arguments.Just a
vector<string>
, which is moved to m_positional (now avector<string>
as well).
m_positional
to find argument names forconsistent short help.
parse()
finally consumes positional arguments in a simple loop.If a vector<> is encountered, it just eats all the remaining arguments.
parse_positional()
is now just a compatibility stub that adds an elementto
m_positional
, although I find it less clear than the above behavior.This should result in the following help:
With no changes to the public interface (and minimal source changes as well).
The text was updated successfully, but these errors were encountered: