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

First example of Arg::default_value_if uses the wrong predicate #4904

Open
2 tasks done
piksel opened this issue May 14, 2023 · 1 comment
Open
2 tasks done

First example of Arg::default_value_if uses the wrong predicate #4904

piksel opened this issue May 14, 2023 · 1 comment
Labels
A-docs Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies
Milestone

Comments

@piksel
Copy link

piksel commented May 14, 2023

Please complete the following tasks

Rust Version

rustc 1.69.0 (84c898d65 2023-04-16)

Clap Version

4.2.2 (also confirmed present in master)

Minimal reproducible code

Not applicable.

Steps to reproduce the bug with the above code

  • Read the examples in docs for Arg::default_value_if.
  • Even though the docs says "using the same test", the predicate is changed in the second example (probably because otherwise it would not pass the assertion).

Actual Behaviour

.default_value_if("flag", ArgPredicate::IsPresent, Some("default")))

The predicate used in the first example doesn't actually do anything, as it sets the default value regardless of whether the flag is passed.

Expected Behaviour

Should use the same predicate as the second example:

.default_value_if("flag", "true", Some("default")))

Additional Context

No response

Debug Output

No response

@piksel piksel added the C-bug Category: Updating dependencies label May 14, 2023
@epage
Copy link
Member

epage commented May 18, 2023

Looks like we have a bug and opened #4918 and the documentation was partially updated to as part of mass updates.

We could do short-term workaround but I'd rather wait for #4918

@epage epage added the A-docs Area: documentation, including docs.rs, readme, examples, etc... label May 18, 2023
@epage epage added this to the 5.0 milestone May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

2 participants