diff --git a/tests/derive/doc_comments_help.rs b/tests/derive/doc_comments_help.rs index d90a04bc90c..f655859e31e 100644 --- a/tests/derive/doc_comments_help.rs +++ b/tests/derive/doc_comments_help.rs @@ -14,7 +14,7 @@ use crate::utils; -use clap::{CommandFactory, Parser, ValueEnum}; +use clap::{CommandFactory, Parser, Subcommand, ValueEnum}; #[test] fn doc_comments() { @@ -248,3 +248,31 @@ fn doc_comment_about_handles_both_abouts() { // comment. assert_eq!(cmd.get_long_about(), None); } + +#[test] +fn respect_subcommand_doc_comment() { + #[derive(Parser, Debug)] + pub enum Cmd { + /// For child + #[command(subcommand)] + Child(Child), + } + + #[derive(Subcommand, Debug)] + pub enum Child { + One, + Twp, + } + + const OUTPUT: &str = "\ +Usage: cmd + +Commands: + child + help Print this message or the help of the given subcommand(s) + +Options: + -h, --help Print help information +"; + utils::assert_output::("cmd --help", OUTPUT, false); +}