From 586e3374f1815f5c716e332b6ecbd2ae7ef30661 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Tue, 18 Jun 2024 12:45:01 -0500 Subject: [PATCH] update try command's help --- crates/nu-cmd-lang/src/core_commands/try_.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/nu-cmd-lang/src/core_commands/try_.rs b/crates/nu-cmd-lang/src/core_commands/try_.rs index 0b399e368a..2003f03a78 100644 --- a/crates/nu-cmd-lang/src/core_commands/try_.rs +++ b/crates/nu-cmd-lang/src/core_commands/try_.rs @@ -10,7 +10,7 @@ impl Command for Try { } fn usage(&self) -> &str { - "Try to run a block, if it fails optionally run a catch block." + "Try to run a block, if it fails optionally run a catch closure." } fn signature(&self) -> nu_protocol::Signature { @@ -18,7 +18,7 @@ impl Command for Try { .input_output_types(vec![(Type::Any, Type::Any)]) .required("try_block", SyntaxShape::Block, "Block to run.") .optional( - "catch_block", + "catch_closure", SyntaxShape::Keyword( b"catch".to_vec(), Box::new(SyntaxShape::OneOf(vec![ @@ -26,7 +26,7 @@ impl Command for Try { SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), ])), ), - "Block to run if try block fails.", + "Closure to run if try block fails.", ) .category(Category::Core) } @@ -85,9 +85,14 @@ impl Command for Try { }, Example { description: "Try to run a missing command", - example: "try { asdfasdf } catch { 'missing' } ", + example: "try { asdfasdf } catch { 'missing' }", result: Some(Value::test_string("missing")), }, + Example { + description: "Try to run a missing command and report the message", + example: "try { asdfasdf } catch { |err| $err.msg }", + result: Some(Value::test_string("External command failed")), + }, ] } }