From 3be198d2f50e1c7bd9536561acd79d67713605e9 Mon Sep 17 00:00:00 2001 From: Coen Fox <9779696+Gymea@users.noreply.github.com> Date: Wed, 13 Jan 2021 05:27:48 +1100 Subject: [PATCH] Don't print description in help if none exists (#2915) --- crates/nu-engine/src/documentation.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/nu-engine/src/documentation.rs b/crates/nu-engine/src/documentation.rs index 76e00b5c0..045acae61 100644 --- a/crates/nu-engine/src/documentation.rs +++ b/crates/nu-engine/src/documentation.rs @@ -127,8 +127,11 @@ pub fn get_documentation( let signature = cmd.signature(); let mut long_desc = String::new(); - long_desc.push_str(&cmd.usage()); - long_desc.push('\n'); + let usage = &cmd.usage(); + if !usage.is_empty() { + long_desc.push_str(usage); + long_desc.push_str("\n\n"); + } let mut subcommands = vec![]; if !config.no_subcommands { @@ -168,7 +171,7 @@ pub fn get_documentation( one_liner.push_str("{flags} "); } - long_desc.push_str(&format!("\nUsage:\n > {}\n", one_liner)); + long_desc.push_str(&format!("Usage:\n > {}\n", one_liner)); if !subcommands.is_empty() { long_desc.push_str("\nSubcommands:\n");