From 360bb3bc11bf7a0a18ba269642704492383eb028 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 31 Jul 2024 16:16:52 -0500 Subject: [PATCH] fix(help): Properly wrap subcommand about Fixes #5607 --- clap_builder/src/output/help_template.rs | 2 +- tests/builder/help.rs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/clap_builder/src/output/help_template.rs b/clap_builder/src/output/help_template.rs index f3a2b02ed33..3abeab1487a 100644 --- a/clap_builder/src/output/help_template.rs +++ b/clap_builder/src/output/help_template.rs @@ -650,7 +650,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> { let spaces = if next_line_help { TAB.len() + NEXT_LINE_INDENT.len() - } else if let Some(true) = arg.map(|a| a.is_positional()) { + } else if arg.map(|a| a.is_positional()).unwrap_or(true) { longest + TAB_WIDTH * 2 } else { longest + TAB_WIDTH * 2 + 4 // See `fn short` for the 4 diff --git a/tests/builder/help.rs b/tests/builder/help.rs index 50027e058cc..fb203b0e59e 100644 --- a/tests/builder/help.rs +++ b/tests/builder/help.rs @@ -577,9 +577,8 @@ Usage: test [OPTIONS] [COMMAND] Commands: sub1 One two three four five six seven eight nine ten eleven - twelve thirteen fourteen fifteen - help Print this message or the help of the given - subcommand(s) + twelve thirteen fourteen fifteen + help Print this message or the help of the given subcommand(s) Options: -a, --all Also do versioning for private crates (will @@ -635,9 +634,8 @@ Usage: test [OPTIONS] [COMMAND] Commands: sub1 One two three four five six seven eight nine ten eleven - twelve thirteen fourteen fifteen - help Print this message or the help of the given - subcommand(s) + twelve thirteen fourteen fifteen + help Print this message or the help of the given subcommand(s) Options: -a, --all Also do versioning for private crates (will