Available on crate feature
unstable-doc
only.Expand description
Testing
clap reports most development errors as debug_assert!
s. Rather than checking every
subcommand, you should have a test that calls
Command::debug_assert
:
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// Network port to use
port: u16,
}
fn main() {
let cli = Cli::parse();
println!("PORT = {}", cli.port);
}
#[test]
fn verify_cli() {
use clap::CommandFactory;
Cli::command().debug_assert()
}