2019-06-25 19:02:53 -04:00
|
|
|
#[cfg(debug_assertions)]
|
2015-08-28 00:03:45 +03:00
|
|
|
#[test]
|
2020-04-24 23:06:13 +03:00
|
|
|
#[should_panic = "Argument names must be unique, but 'arg1' is in use by more than one argument or group"]
|
2015-08-28 00:03:45 +03:00
|
|
|
fn unique_arg_names() {
|
2022-02-11 21:48:29 -06:00
|
|
|
use clap::{Arg, Command};
|
2020-05-31 17:53:24 +03:00
|
|
|
|
2022-02-11 21:48:29 -06:00
|
|
|
let _ = Command::new("some")
|
2020-05-14 22:50:56 +02:00
|
|
|
.args(&[Arg::new("arg1").short('a'), Arg::new("arg1").short('b')])
|
2018-10-19 16:42:13 -04:00
|
|
|
.try_get_matches();
|
2015-08-28 00:03:45 +03:00
|
|
|
}
|
|
|
|
|
2019-06-25 19:02:53 -04:00
|
|
|
#[cfg(debug_assertions)]
|
2015-08-28 00:03:45 +03:00
|
|
|
#[test]
|
2020-04-24 23:06:13 +03:00
|
|
|
#[should_panic = "Short option names must be unique for each argument, but '-a' is in use by both 'arg1' and 'arg2'"]
|
2015-08-28 00:03:45 +03:00
|
|
|
fn unique_arg_shorts() {
|
2022-02-11 21:48:29 -06:00
|
|
|
use clap::{Arg, Command};
|
2020-05-31 17:53:24 +03:00
|
|
|
|
2022-02-11 21:48:29 -06:00
|
|
|
let _ = Command::new("some")
|
2020-05-14 22:50:56 +02:00
|
|
|
.args(&[Arg::new("arg1").short('a'), Arg::new("arg2").short('a')])
|
2018-10-19 16:42:13 -04:00
|
|
|
.try_get_matches();
|
2015-08-28 00:03:45 +03:00
|
|
|
}
|
|
|
|
|
2019-06-25 19:02:53 -04:00
|
|
|
#[cfg(debug_assertions)]
|
2015-08-28 00:03:45 +03:00
|
|
|
#[test]
|
2020-04-24 23:06:13 +03:00
|
|
|
#[should_panic = "Long option names must be unique for each argument, but '--long' is in use by both 'arg1' and 'arg2'"]
|
2015-08-28 00:03:45 +03:00
|
|
|
fn unique_arg_longs() {
|
2022-02-11 21:48:29 -06:00
|
|
|
use clap::{Arg, Command};
|
2020-05-31 17:53:24 +03:00
|
|
|
|
2022-02-11 21:48:29 -06:00
|
|
|
let _ = Command::new("some")
|
2020-05-14 22:50:56 +02:00
|
|
|
.args(&[Arg::new("arg1").long("long"), Arg::new("arg2").long("long")])
|
2018-10-19 16:42:13 -04:00
|
|
|
.try_get_matches();
|
2016-01-21 01:48:30 -05:00
|
|
|
}
|