mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
20 lines
629 B
Rust
20 lines
629 B
Rust
|
use clap::{App, Arg};
|
||
|
|
||
|
#[cfg(debug_assertions)]
|
||
|
#[test]
|
||
|
#[should_panic = "Argument 'test' has both `validator` and `validator_os` set which is not allowed"]
|
||
|
fn both_validator_and_validator_os() {
|
||
|
let _ = App::new("test")
|
||
|
.arg(
|
||
|
Arg::with_name("test")
|
||
|
.validator(|val| val.parse::<u32>().map_err(|e| e.to_string()))
|
||
|
.validator_os(|val| {
|
||
|
val.to_str()
|
||
|
.unwrap()
|
||
|
.parse::<u32>()
|
||
|
.map_err(|e| e.to_string())
|
||
|
}),
|
||
|
)
|
||
|
.try_get_matches_from(&["app", "1"]);
|
||
|
}
|