diff --git a/crates/nu-command/src/core_commands/try_.rs b/crates/nu-command/src/core_commands/try_.rs
index 8503c6ea96..22e2ef63f4 100644
--- a/crates/nu-command/src/core_commands/try_.rs
+++ b/crates/nu-command/src/core_commands/try_.rs
@@ -20,7 +20,7 @@ impl Command for Try {
.input_output_types(vec![(Type::Any, Type::Any)])
.required("try_block", SyntaxShape::Block, "block to run")
.optional(
- "else_expression",
+ "catch_block",
SyntaxShape::Keyword(
b"catch".to_vec(),
Box::new(SyntaxShape::Closure(Some(vec![SyntaxShape::Any]))),
diff --git a/crates/nu-command/tests/format_conversions/html.rs b/crates/nu-command/tests/format_conversions/html.rs
index f8fe618fb7..1a5824620f 100644
--- a/crates/nu-command/tests/format_conversions/html.rs
+++ b/crates/nu-command/tests/format_conversions/html.rs
@@ -57,7 +57,7 @@ fn test_cd_html_color_flag_dark_false() {
);
assert_eq!(
actual.out,
- r"
Change directory.
Usage:
> cd (path)
Flags:
-h, --help
Display the help message for this command
Parameters:
(optional) path <Directory>: the path to change to
Examples:
Change to your home directory
> cd ~
Change to a directory via abbreviations
> cd d/s/9
Change to the previous working directory ($OLDPWD)
> cd -
"
+ r"Change directory.
Usage:
> cd (path)
Flags:
-h, --help
Display the help message for this command
Parameters:
(optional) path <directory>: the path to change to
Examples:
Change to your home directory
> cd ~
Change to a directory via abbreviations
> cd d/s/9
Change to the previous working directory ($OLDPWD)
> cd -
"
);
}
@@ -72,7 +72,7 @@ fn test_no_color_flag() {
);
assert_eq!(
actual.out,
- r"Change directory.
Usage:
> cd (path)
Flags:
-h, --help - Display the help message for this command
Parameters:
(optional) path <Directory>: the path to change to
Examples:
Change to your home directory
> cd ~
Change to a directory via abbreviations
> cd d/s/9
Change to the previous working directory ($OLDPWD)
> cd -
"
+ r"Change directory.
Usage:
> cd (path)
Flags:
-h, --help - Display the help message for this command
Parameters:
(optional) path <directory>: the path to change to
Examples:
Change to your home directory
> cd ~
Change to a directory via abbreviations
> cd d/s/9
Change to the previous working directory ($OLDPWD)
> cd -
"
);
}
diff --git a/crates/nu-engine/src/documentation.rs b/crates/nu-engine/src/documentation.rs
index c736521dda..61a7e00208 100644
--- a/crates/nu-engine/src/documentation.rs
+++ b/crates/nu-engine/src/documentation.rs
@@ -116,27 +116,51 @@ fn get_documentation(
{
let _ = write!(long_desc, "\n{G}Parameters{RESET}:\n");
for positional in &sig.required_positional {
- let text = format!(
- " {C}{}{RESET} <{BB}{:?}{RESET}>: {}",
- positional.name,
- document_shape(positional.shape.clone()),
- positional.desc
- );
+ let text = match &positional.shape {
+ SyntaxShape::Keyword(kw, shape) => {
+ format!(
+ " {C}\"{}\" + {RESET}<{BB}{}{RESET}>: {}",
+ String::from_utf8_lossy(kw),
+ document_shape(*shape.clone()),
+ positional.desc
+ )
+ }
+ _ => {
+ format!(
+ " {C}{}{RESET} <{BB}{}{RESET}>: {}",
+ positional.name,
+ document_shape(positional.shape.clone()),
+ positional.desc
+ )
+ }
+ };
let _ = writeln!(long_desc, "{}", text);
}
for positional in &sig.optional_positional {
- let text = format!(
- " (optional) {C}{}{RESET} <{BB}{:?}{RESET}>: {}",
- positional.name,
- document_shape(positional.shape.clone()),
- positional.desc
- );
+ let text = match &positional.shape {
+ SyntaxShape::Keyword(kw, shape) => {
+ format!(
+ " (optional) {C}\"{}\" + {RESET}<{BB}{}{RESET}>: {}",
+ String::from_utf8_lossy(kw),
+ document_shape(*shape.clone()),
+ positional.desc
+ )
+ }
+ _ => {
+ format!(
+ " (optional) {C}{}{RESET} <{BB}{}{RESET}>: {}",
+ positional.name,
+ document_shape(positional.shape.clone()),
+ positional.desc
+ )
+ }
+ };
let _ = writeln!(long_desc, "{}", text);
}
if let Some(rest_positional) = &sig.rest_positional {
let text = format!(
- " ...{C}{}{RESET} <{BB}{:?}{RESET}>: {}",
+ " ...{C}{}{RESET} <{BB}{}{RESET}>: {}",
rest_positional.name,
document_shape(rest_positional.shape.clone()),
rest_positional.desc
diff --git a/crates/nu-plugin/src/plugin/mod.rs b/crates/nu-plugin/src/plugin/mod.rs
index 62d1ba4893..4fd3e46d0a 100644
--- a/crates/nu-plugin/src/plugin/mod.rs
+++ b/crates/nu-plugin/src/plugin/mod.rs
@@ -329,7 +329,7 @@ fn print_help(plugin: &mut impl Plugin, encoder: impl PluginEncoder) {
.try_for_each(|positional| {
writeln!(
help,
- " {} <{:?}>: {}",
+ " {} <{}>: {}",
positional.name, positional.shape, positional.desc
)
})
@@ -341,7 +341,7 @@ fn print_help(plugin: &mut impl Plugin, encoder: impl PluginEncoder) {
.try_for_each(|positional| {
writeln!(
help,
- " (optional) {} <{:?}>: {}",
+ " (optional) {} <{}>: {}",
positional.name, positional.shape, positional.desc
)
})
@@ -350,7 +350,7 @@ fn print_help(plugin: &mut impl Plugin, encoder: impl PluginEncoder) {
if let Some(rest_positional) = &signature.rest_positional {
writeln!(
help,
- " ...{} <{:?}>: {}",
+ " ...{} <{}>: {}",
rest_positional.name, rest_positional.shape, rest_positional.desc
)
} else {
diff --git a/crates/nu-protocol/src/syntax_shape.rs b/crates/nu-protocol/src/syntax_shape.rs
index d9d7244ac6..bca1c0f065 100644
--- a/crates/nu-protocol/src/syntax_shape.rs
+++ b/crates/nu-protocol/src/syntax_shape.rs
@@ -165,7 +165,15 @@ impl Display for SyntaxShape {
SyntaxShape::GlobPattern => write!(f, "glob"),
SyntaxShape::ImportPattern => write!(f, "import"),
SyntaxShape::Block => write!(f, "block"),
- SyntaxShape::Closure(_) => write!(f, "closure"),
+ SyntaxShape::Closure(args) => {
+ if let Some(args) = args {
+ let arg_vec: Vec<_> = args.iter().map(|x| x.to_string()).collect();
+ let arg_string = arg_vec.join(", ");
+ write!(f, "closure({})", arg_string)
+ } else {
+ write!(f, "closure()")
+ }
+ }
SyntaxShape::Binary => write!(f, "binary"),
SyntaxShape::Table => write!(f, "table"),
SyntaxShape::List(x) => write!(f, "list<{}>", x),