mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
improve error when name and parameters are not space-separated (#8958)
# Description closes #8934 this pr improves the diagnostic emitted when the name and parameters of either `def`, `def-env` or `extern` are not separated by a space ```nu Error: × no space between name and parameters ╭─[entry #1:1:1] 1 │ def err[] {} · ▲ · ╰── expected space ╰──── help: consider adding a space between the `def` command's name and its parameters ``` from ```nu Error: nu::parser::missing_positional × Missing required positional argument. ╭─[entry #1:1:1] 1 │ def err[] {} ╰──── help: Usage: def <def_name> <params> <body> ``` --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com> Co-authored-by: Jelle Besseling <jelle@pingiun.com>
This commit is contained in:
@ -37,6 +37,20 @@ param:string #My cool attractive param
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn def_errors_with_no_space_between_params_and_name_1() {
|
||||
let actual = nu!("def test-command[] {}");
|
||||
|
||||
assert!(actual.err.contains("expected space"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn def_errors_with_no_space_between_params_and_name_2() {
|
||||
let actual = nu!("def-env test-command() {}");
|
||||
|
||||
assert!(actual.err.contains("expected space"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn def_errors_with_multiple_short_flags() {
|
||||
let actual = nu!("def test-command [ --long(-l)(-o) ] {}");
|
||||
|
Reference in New Issue
Block a user