-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(parser): Ban long flags with literals #2619
Conversation
I wish overrides-self was a default :). It'd especially make sense in this case but people can still relatively easily opt-in, if they know how. |
Looking over #1649, it doesn't look like there was consensus on moving forward with this. It also looked like it was possible to implement this by users in clap today. I'm particularly concerned about
|
@epage As a I have an idea: to avoid possible argues about How will this decision affect the usage of |
... I didn't want to believe this but I threw in a test real quick assert_eq!(
Opt { alice: true },
Opt::parse_from(&["test", "--alice=false"])
); imo thats bad and seems like a bug in the parser. If there is a |
@pksunkara After some consideration, at this point I'm leaning towards modifying my original code to ban @epage What's worse, the same problem exists with env flags, see #2539. |
@epage @pksunkara So I have just banned all usage of flags with a literal, giving a The rest of this problem is to somehow make users of this crate more aware of the If this gets accepted, I will then make another PR on env variables. |
imo we should have a place to document common arg patterns. Unsure if |
I take it you are proposing we close #1649 out by rejecting the proposed idea and instead document how to use existing clap APIs? As I said earlier, I hadn't seen consensus on it. No idea what clap's decision making process is like to say whether documenting is a way of closing #1649 or to just unblock people until a decision is made. This is why I was assuming #1649 was going to be taken out of this PR. One thing gained by decoupling the decision over #1649 from this PR is it means it doesn't have to be bogged down before merging useful improvements. |
@epage Thanks for clarifying. Sorry, clearly I wasn't very well thought out, since it turns out that soon we might be discussing the very same problem over again with env variables... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example file still has changes.
Closes #1543.
The objective of this PR is to ban use of literals with long flags (long args without
TakesValue
), eg.--flag=literal
, in order to avoid the current confusion that--flag=false
is considered astrue
.Ideally,
--flag=literal
could be re-enabled for certain values ofliteral
, but the choice of such values is left for further discussion (in #1649 for CLI flags, and #2539 for environment variables).Unresolved Questions
How should this interact with multiple occurrences?