-
Notifications
You must be signed in to change notification settings - Fork 4
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
stdin argument used more than once when argument is not in the final subcommand #9
Comments
A workaround for the default not working is to set it to |
This change relaxes the check for duplicate usage of `stdin` on arg declarations (error at runtime if any two args use `MaybeStdin` or `FileOrStdin`) and instead only check for duplicated `stdin` usage when these args are accessed. This allows usages of args that may be mutually exclusive (E.g. under different subcommands) or use the `global=true` clap option (as reported in #9) If a tool happens to accept multiple args that can be Stdin, the CLI user will only see an error if they actually try to use `stdin` for values twice.
This change relaxes the check for duplicate usage of `stdin` on arg declarations (error at runtime if any two args use `MaybeStdin` or `FileOrStdin`) and instead only check for duplicated `stdin` usage when these args are accessed. This allows usages of args that may be mutually exclusive (E.g. under different subcommands) or use the `global=true` clap option (as reported in #9) If a tool happens to accept multiple args that can be Stdin, the CLI user will only see an error if they actually try to use `stdin` for values twice.
@RGBCube thank you for reporting!! I believe you are running into this issue because of the The incompatibility ended up being from a side affect of checking for stdin usage when args are parsed instead of when Please feel free to test that PR (I confirmed it works with your example above) and let me know if that resolves the issue. If so, I'll merge and release a new version soon. |
This change relaxes the check for duplicate usage of `stdin` on arg declarations (error at runtime if any two args use `MaybeStdin` or `FileOrStdin`) and instead only check for duplicated `stdin` usage when these args are accessed. This allows usages of args that may be mutually exclusive (E.g. under different subcommands) or use the `global=true` clap option (as reported in #9) If a tool happens to accept multiple args that can be Stdin, the CLI user will only see an error if they actually try to use `stdin` for values twice.
(i suppose you mean This PR indeed fixes it, but won't this regress program behavior? If I'm understanding correctly, if I accepted two FileOrStdins and the user passed in What if instead of this, the argument was checked when the FileOrStdin was created, and the atomic was changed when it was? So when clap tries to construct the second FileOrStdin with once again |
Ah, after looking at the changes, this was already the case before. Disregard my previous comment then :) After thinking a little more about it, I can actually see the "lazy" behavior being useful for flags which are accessed based on behavior. |
whoops, yes,
This is what the previous code did, but that seems to be an issue with |
This change relaxes the check for duplicate usage of `stdin` on arg declarations (error at runtime if any two args use `MaybeStdin` or `FileOrStdin`) and instead only check for duplicated `stdin` usage when these args are accessed. This allows usages of args that may be mutually exclusive (E.g. under different subcommands) or use the `global=true` clap option (as reported in #9) If a tool happens to accept multiple args that can be Stdin, the CLI user will only see an error if they actually try to use `stdin` for values twice.
Fix released in v0.5.0 |
MRE
Then run the resulting binary as
<binary> foo
:If this isn't solveable, a feature that disables the "more than one stdin" check would be useful for cases where there is only a single file.
(note that
<binary> foo <filehere>
works, as expected)The text was updated successfully, but these errors were encountered: