mirror of
https://github.com/clap-rs/clap
synced 2024-11-14 00:27:13 +00:00
Support loading help_message and version_message from the YAML
This commit is contained in:
parent
389c413b70
commit
c5dac3fa43
3 changed files with 17 additions and 0 deletions
|
@ -1467,6 +1467,8 @@ impl<'a> From<&'a Yaml> for App<'a, 'a> {
|
||||||
yaml_str!(a, yaml, help);
|
yaml_str!(a, yaml, help);
|
||||||
yaml_str!(a, yaml, help_short);
|
yaml_str!(a, yaml, help_short);
|
||||||
yaml_str!(a, yaml, version_short);
|
yaml_str!(a, yaml, version_short);
|
||||||
|
yaml_str!(a, yaml, help_message);
|
||||||
|
yaml_str!(a, yaml, version_message);
|
||||||
yaml_str!(a, yaml, alias);
|
yaml_str!(a, yaml, alias);
|
||||||
yaml_str!(a, yaml, visible_alias);
|
yaml_str!(a, yaml, visible_alias);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ about: tests clap library
|
||||||
author: Kevin K. <kbknapp@gmail.com>
|
author: Kevin K. <kbknapp@gmail.com>
|
||||||
settings:
|
settings:
|
||||||
- ArgRequiredElseHelp
|
- ArgRequiredElseHelp
|
||||||
|
help_message: prints help with a nonstandard description
|
||||||
args:
|
args:
|
||||||
- opt:
|
- opt:
|
||||||
short: o
|
short: o
|
||||||
|
|
|
@ -10,3 +10,17 @@ fn create_app_from_yaml() {
|
||||||
let yml = load_yaml!("app.yml");
|
let yml = load_yaml!("app.yml");
|
||||||
App::from_yaml(yml);
|
App::from_yaml(yml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn help_message() {
|
||||||
|
let yml = load_yaml!("app.yml");
|
||||||
|
let mut app = App::from_yaml(yml);
|
||||||
|
// Generate the full help message!
|
||||||
|
let _ = app.get_matches_from_safe_borrow(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"));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue