mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
59f3e9414b
this implements Arg::short_alias, Arg::short_aliases, Arg::short_visible_alias, and Arg::short_visible_aliases in addition to adding their associated tests
43 lines
1.3 KiB
Rust
43 lines
1.3 KiB
Rust
#![cfg(feature = "yaml")]
|
|
|
|
use clap::{load_yaml, App};
|
|
|
|
#[test]
|
|
fn create_app_from_yaml() {
|
|
let yml = load_yaml!("fixtures/app.yml");
|
|
App::from(yml);
|
|
}
|
|
|
|
// TODO: Uncomment to test yaml with 2 spaces https://github.com/chyh1990/yaml-rust/issues/101
|
|
// #[test]
|
|
// fn create_app_from_yaml_2spaces() {
|
|
// let yml = load_yaml!("fixtures/app_2space.yml");
|
|
// App::from(yml);
|
|
// }
|
|
|
|
#[test]
|
|
fn help_message() {
|
|
let yml = load_yaml!("fixtures/app.yml");
|
|
let mut app = App::from(yml);
|
|
// Generate the full help message!
|
|
let _ = app.try_get_matches_from_mut(Vec::<String>::new());
|
|
|
|
let mut help_buffer = Vec::new();
|
|
app.write_help(&mut help_buffer).unwrap();
|
|
let help_string = String::from_utf8(help_buffer).unwrap();
|
|
assert!(help_string
|
|
.contains("-h, --help prints help with a nonstandard description\n"));
|
|
}
|
|
|
|
#[test]
|
|
fn author() {
|
|
let yml = load_yaml!("fixtures/app.yml");
|
|
let mut app = App::from(yml);
|
|
// Generate the full help message!
|
|
let _ = app.try_get_matches_from_mut(Vec::<String>::new());
|
|
|
|
let mut help_buffer = Vec::new();
|
|
app.write_help(&mut help_buffer).unwrap();
|
|
let help_string = String::from_utf8(help_buffer).unwrap();
|
|
assert!(help_string.contains("Kevin K. <kbknapp@gmail.com>"));
|
|
}
|