mirror of
https://github.com/clap-rs/clap
synced 2024-12-15 07:12:32 +00:00
b190a6a817
This reduces the need for us to have `clap` as a dependency in `clap_derive`, preparing the way to fix #15.
97 lines
2.1 KiB
Rust
97 lines
2.1 KiB
Rust
use clap::IntoApp;
|
|
use clap::Parser;
|
|
#[test]
|
|
fn app_name_in_short_help_from_struct() {
|
|
#[derive(Parser)]
|
|
#[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() {
|
|
#[derive(Parser)]
|
|
#[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() {
|
|
#[derive(Parser)]
|
|
#[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() {
|
|
#[derive(Parser)]
|
|
#[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() {
|
|
#[derive(Parser)]
|
|
#[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() {
|
|
#[derive(Parser)]
|
|
#[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() {
|
|
#[derive(Parser)]
|
|
#[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() {
|
|
#[derive(Parser)]
|
|
#[clap(name = "my-app")]
|
|
enum MyApp {}
|
|
|
|
let version = MyApp::into_app().render_long_version();
|
|
|
|
assert!(version.contains("my-app"));
|
|
}
|