From dcda7a4e50053edde6e4325bb2c136c0c2a90067 Mon Sep 17 00:00:00 2001 From: JT Date: Thu, 14 Oct 2021 06:58:39 +1300 Subject: [PATCH] Touchups to help --- crates/nu-engine/src/documentation.rs | 44 +++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/crates/nu-engine/src/documentation.rs b/crates/nu-engine/src/documentation.rs index 928320fc2..84fe44fa1 100644 --- a/crates/nu-engine/src/documentation.rs +++ b/crates/nu-engine/src/documentation.rs @@ -260,11 +260,28 @@ fn get_flags_section(signature: &Signature) -> String { if let Some(short) = flag.short { if flag.required { format!( - " -{}, --{} (required parameter){:?} {}\n", - short, flag.long, arg, flag.desc + " -{}{} (required parameter){:?} {}\n", + short, + if !flag.long.is_empty() { + format!(", --{}", flag.long) + } else { + "".into() + }, + arg, + flag.desc ) } else { - format!(" -{}, --{} {:?} {}\n", short, flag.long, arg, flag.desc) + format!( + " -{}{} {:?} {}\n", + short, + if !flag.long.is_empty() { + format!(", --{}", flag.long) + } else { + "".into() + }, + arg, + flag.desc + ) } } else if flag.required { format!( @@ -277,11 +294,26 @@ fn get_flags_section(signature: &Signature) -> String { } else if let Some(short) = flag.short { if flag.required { format!( - " -{}, --{} (required parameter) {}\n", - short, flag.long, flag.desc + " -{}{} (required parameter) {}\n", + short, + if !flag.long.is_empty() { + format!(", --{}", flag.long) + } else { + "".into() + }, + flag.desc ) } else { - format!(" -{}, --{} {}\n", short, flag.long, flag.desc) + format!( + " -{}{} {}\n", + short, + if !flag.long.is_empty() { + format!(", --{}", flag.long) + } else { + "".into() + }, + flag.desc + ) } } else if flag.required { format!(" --{} (required parameter) {}\n", flag.long, flag.desc)