mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
68377c176d
# 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
27 lines
867 B
Rust
27 lines
867 B
Rust
use crate::repl::tests::{run_test, TestResult};
|
|
use rstest::rstest;
|
|
|
|
#[rstest]
|
|
// avoid feeding strings containing parens to regex. Does not end well.
|
|
#[case(": arga help")]
|
|
#[case("argb help")]
|
|
#[case("optional, default: 20")]
|
|
#[case(": f1 switch")]
|
|
#[case(": f2 named no default")]
|
|
#[case(": f3 named default 3")]
|
|
#[case("default: 33")]
|
|
#[case("--help: Display the help message")]
|
|
fn can_get_help(#[case] exp_result: &str) -> TestResult {
|
|
run_test(
|
|
&format!(
|
|
r#"def t [a:string, # arga help
|
|
b:int=20, # argb help
|
|
--f1, # f1 switch help
|
|
--f2:string, # f2 named no default
|
|
--f3:int=33 # f3 named default 3
|
|
] {{ true }};
|
|
help t | ansi strip | find `{exp_result}` | get 0 | str replace --all --regex '^(.*({exp_result}).*)$' '$2'"#,
|
|
),
|
|
exp_result,
|
|
)
|
|
}
|