mirror of
https://github.com/nushell/nushell
synced 2024-12-26 13:03:07 +00:00
Remove superfluous separator when there's no flag description/comment (#14007)
# Description Fixes a small side-issue in #10977 - If a command flag didn't have a comment/description, it would still show an unnecessary separator at the end of the line. This fixes that, plus uses the `: ` (colon) to separate the flag from the description. This aligns with the way that named parameters are handled. # User-Facing Changes Help/doc only # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
This commit is contained in:
parent
baadaee016
commit
68377c176d
2 changed files with 7 additions and 5 deletions
|
@ -572,7 +572,9 @@ where
|
|||
document_shape(arg)
|
||||
);
|
||||
}
|
||||
let _ = write!(long_desc, " - {}", flag.desc);
|
||||
if !flag.desc.is_empty() {
|
||||
let _ = write!(long_desc, ": {}", flag.desc);
|
||||
}
|
||||
if let Some(value) = &flag.default_value {
|
||||
let _ = write!(long_desc, " (default: {})", &value_formatter(value));
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ use rstest::rstest;
|
|||
#[case(": arga help")]
|
||||
#[case("argb help")]
|
||||
#[case("optional, default: 20")]
|
||||
#[case("- f1 switch")]
|
||||
#[case("- f2 named no default")]
|
||||
#[case("- f3 named default 3")]
|
||||
#[case(": f1 switch")]
|
||||
#[case(": f2 named no default")]
|
||||
#[case(": f3 named default 3")]
|
||||
#[case("default: 33")]
|
||||
#[case("--help - Display the help message")]
|
||||
#[case("--help: Display the help message")]
|
||||
fn can_get_help(#[case] exp_result: &str) -> TestResult {
|
||||
run_test(
|
||||
&format!(
|
||||
|
|
Loading…
Reference in a new issue