clap
clap copied to clipboard
Lifetime of possible values and PossibleValueParser
Please complete the following tasks
- [X] I have searched the discussions
- [X] I have searched the open and rejected issues
Rust Version
rustc 1.62.1 (e092d0b6b 2022-07-16)
Clap Version
3.2.16
Minimal reproducible code
use clap::{command, Arg};
fn main() {
let possible_values: Vec<&str> = vec!["abc", "def"];
let app = command!().arg(Arg::new("example").possible_values(&possible_values));
let matches = app.get_matches();
println!("{:#?}", matches);
}
Steps to reproduce the bug with the above code
I'm trying to build a dynamic command line interface, where possible options are read from a config file. This is currently possible as .possible_values()
requires 'help
lifetime, but the new PossibleValueParser
implementation requires 'static
lifetime.
Actual Behaviour
N/A
Expected Behaviour
N/A
Additional Context
No response
Debug Output
No response
We can't add lifetimes to PossibleValueParser
without a breaking change and on next breaking change, we're hoping to remove lifetimes completely, see https://github.com/clap-rs/clap/issues/1041.
Resolved in #4097