2021-02-22 13:54:15 +00:00
|
|
|
use clap::IntoApp;
|
2021-07-13 17:50:55 +00:00
|
|
|
use clap::Parser;
|
2021-02-22 13:54:15 +00:00
|
|
|
#[test]
|
|
|
|
fn app_name_in_short_help_from_struct() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Parser)]
|
2021-02-22 13:54:15 +00:00
|
|
|
#[clap(name = "my-app")]
|
|
|
|
struct MyApp {}
|
|
|
|
|
|
|
|
let mut help = Vec::new();
|
|
|
|
MyApp::into_app().write_help(&mut help).unwrap();
|
|
|
|
let help = String::from_utf8(help).unwrap();
|
|
|
|
|
|
|
|
assert!(help.contains("my-app"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn app_name_in_long_help_from_struct() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Parser)]
|
2021-02-22 13:54:15 +00:00
|
|
|
#[clap(name = "my-app")]
|
|
|
|
struct MyApp {}
|
|
|
|
|
|
|
|
let mut help = Vec::new();
|
|
|
|
MyApp::into_app().write_long_help(&mut help).unwrap();
|
|
|
|
let help = String::from_utf8(help).unwrap();
|
|
|
|
|
|
|
|
assert!(help.contains("my-app"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn app_name_in_short_help_from_enum() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Parser)]
|
2021-02-22 13:54:15 +00:00
|
|
|
#[clap(name = "my-app")]
|
|
|
|
enum MyApp {}
|
|
|
|
|
|
|
|
let mut help = Vec::new();
|
|
|
|
MyApp::into_app().write_help(&mut help).unwrap();
|
|
|
|
let help = String::from_utf8(help).unwrap();
|
|
|
|
|
|
|
|
assert!(help.contains("my-app"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn app_name_in_long_help_from_enum() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Parser)]
|
2021-02-22 13:54:15 +00:00
|
|
|
#[clap(name = "my-app")]
|
|
|
|
enum MyApp {}
|
|
|
|
|
|
|
|
let mut help = Vec::new();
|
|
|
|
MyApp::into_app().write_long_help(&mut help).unwrap();
|
|
|
|
let help = String::from_utf8(help).unwrap();
|
|
|
|
|
|
|
|
assert!(help.contains("my-app"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn app_name_in_short_version_from_struct() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Parser)]
|
2021-02-22 13:54:15 +00:00
|
|
|
#[clap(name = "my-app")]
|
|
|
|
struct MyApp {}
|
|
|
|
|
|
|
|
let version = MyApp::into_app().render_version();
|
|
|
|
|
|
|
|
assert!(version.contains("my-app"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn app_name_in_long_version_from_struct() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Parser)]
|
2021-02-22 13:54:15 +00:00
|
|
|
#[clap(name = "my-app")]
|
|
|
|
struct MyApp {}
|
|
|
|
|
|
|
|
let version = MyApp::into_app().render_long_version();
|
|
|
|
|
|
|
|
assert!(version.contains("my-app"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn app_name_in_short_version_from_enum() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Parser)]
|
2021-02-22 13:54:15 +00:00
|
|
|
#[clap(name = "my-app")]
|
|
|
|
enum MyApp {}
|
|
|
|
|
|
|
|
let version = MyApp::into_app().render_version();
|
|
|
|
|
|
|
|
assert!(version.contains("my-app"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn app_name_in_long_version_from_enum() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Parser)]
|
2021-02-22 13:54:15 +00:00
|
|
|
#[clap(name = "my-app")]
|
|
|
|
enum MyApp {}
|
|
|
|
|
|
|
|
let version = MyApp::into_app().render_long_version();
|
|
|
|
|
|
|
|
assert!(version.contains("my-app"));
|
|
|
|
}
|