1 #![cfg(feature = "cargo")] 2 3 use clap::{command, error::ErrorKind}; 4 5 use crate::utils; 6 7 static EVERYTHING: &str = "clap {{version}} 8 A simple to use, efficient, and full-featured Command Line Argument Parser 9 10 Usage: clap 11 12 Options: 13 -h, --help Print help 14 -V, --version Print version 15 "; 16 17 #[test] command()18fn command() { 19 let res = command!() 20 .help_template(utils::FULL_TEMPLATE) 21 .try_get_matches_from(vec!["clap", "--help"]); 22 23 assert!(res.is_err()); 24 let err = res.unwrap_err(); 25 assert_eq!(err.kind(), ErrorKind::DisplayHelp); 26 assert_eq!( 27 err.to_string(), 28 EVERYTHING.replace("{{version}}", env!("CARGO_PKG_VERSION")) 29 ); 30 } 31