mirror of
https://github.com/clap-rs/clap
synced 2024-11-15 00:57:15 +00:00
4280fdfcbd
The writer is less convenient and isn't offering any performance benefits of avoidign the extra allocations, so let's render instead. This supersedes #3874 Fixes #3873
93 lines
1.8 KiB
Rust
93 lines
1.8 KiB
Rust
use clap::CommandFactory;
|
|
use clap::Parser;
|
|
|
|
use crate::utils::get_help;
|
|
use crate::utils::get_long_help;
|
|
|
|
#[test]
|
|
fn app_name_in_short_help_from_struct() {
|
|
#[derive(Parser)]
|
|
#[command(name = "my-cmd")]
|
|
struct MyApp {}
|
|
|
|
let help = get_help::<MyApp>();
|
|
|
|
assert!(help.contains("my-cmd"));
|
|
}
|
|
|
|
#[test]
|
|
fn app_name_in_long_help_from_struct() {
|
|
#[derive(Parser)]
|
|
#[command(name = "my-cmd")]
|
|
struct MyApp {}
|
|
|
|
let help = get_help::<MyApp>();
|
|
|
|
assert!(help.contains("my-cmd"));
|
|
}
|
|
|
|
#[test]
|
|
fn app_name_in_short_help_from_enum() {
|
|
#[derive(Parser)]
|
|
#[command(name = "my-cmd")]
|
|
enum MyApp {}
|
|
|
|
let help = get_help::<MyApp>();
|
|
|
|
assert!(help.contains("my-cmd"));
|
|
}
|
|
|
|
#[test]
|
|
fn app_name_in_long_help_from_enum() {
|
|
#[derive(Parser)]
|
|
#[command(name = "my-cmd")]
|
|
enum MyApp {}
|
|
|
|
let help = get_long_help::<MyApp>();
|
|
|
|
assert!(help.contains("my-cmd"));
|
|
}
|
|
|
|
#[test]
|
|
fn app_name_in_short_version_from_struct() {
|
|
#[derive(Parser)]
|
|
#[command(name = "my-cmd")]
|
|
struct MyApp {}
|
|
|
|
let version = MyApp::command().render_version();
|
|
|
|
assert!(version.contains("my-cmd"));
|
|
}
|
|
|
|
#[test]
|
|
fn app_name_in_long_version_from_struct() {
|
|
#[derive(Parser)]
|
|
#[command(name = "my-cmd")]
|
|
struct MyApp {}
|
|
|
|
let version = MyApp::command().render_long_version();
|
|
|
|
assert!(version.contains("my-cmd"));
|
|
}
|
|
|
|
#[test]
|
|
fn app_name_in_short_version_from_enum() {
|
|
#[derive(Parser)]
|
|
#[command(name = "my-cmd")]
|
|
enum MyApp {}
|
|
|
|
let version = MyApp::command().render_version();
|
|
|
|
assert!(version.contains("my-cmd"));
|
|
}
|
|
|
|
#[test]
|
|
fn app_name_in_long_version_from_enum() {
|
|
#[derive(Parser)]
|
|
#[command(name = "my-cmd")]
|
|
enum MyApp {}
|
|
|
|
let version = MyApp::command().render_long_version();
|
|
|
|
assert!(version.contains("my-cmd"));
|
|
}
|