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

Clarify behaviour of from_iter regarding the first element #380

Closed
dbdr opened this issue Apr 22, 2020 · 2 comments · Fixed by #381
Closed

Clarify behaviour of from_iter regarding the first element #380

dbdr opened this issue Apr 22, 2020 · 2 comments · Fixed by #381

Comments

@dbdr
Copy link

dbdr commented Apr 22, 2020

When using from_args, the first argument is of course the executable name. When using StructOpt::from_iter, it was not clear to me if the first element would be treated in the same way or not (it seems it is). I'm not sure what the "best" behavior would be, both might be surprising to some users. In any case I think it would be useful to mention this aspect in the doc of from_iter, especially since the first argument has not been parsed as an option might lead to silently not behaving as the user expects.

@CreepySkeleton
Copy link
Collaborator

structopt works on top of clap. The arguments are passed straight to
App::get_matches_from_safe, which expresses this behavior rather well:

NOTE: The first argument will be parsed as the binary name unless AppSettings::NoBinaryName is used

Moreover, many command line parsers work the same way: they expect the first argument to be the name of the executable unless explicitly specified otherwise. But yes, this may confuse some newcomers, and this is why we have the documentation to point to.

I will attach the note to the methods in question. Well spotted!

@dbdr
Copy link
Author

dbdr commented Apr 22, 2020

Great, thanks a lot for your amazing work!

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