From 1c15a4ed3a9ba678cee80e0291908d13e6ea4859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Cortier?= Date: Wed, 29 Jun 2022 18:43:46 -0400 Subject: [PATCH] docs: clarify `print` and `echo` commands (#5909) I thought this comment was relevant: https://github.com/nushell/nushell/issues/5724#issuecomment-1148164153 --- crates/nu-cli/src/print.rs | 9 ++++++++- crates/nu-command/src/core_commands/echo.rs | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/nu-cli/src/print.rs b/crates/nu-cli/src/print.rs index fff36de54..499b120cb 100644 --- a/crates/nu-cli/src/print.rs +++ b/crates/nu-cli/src/print.rs @@ -25,7 +25,14 @@ impl Command for Print { } fn usage(&self) -> &str { - "Prints the values given" + "Print the given values to stdout" + } + + fn extra_usage(&self) -> &str { + r#"Unlike `echo`, this command does not return any value (`print | describe` will return "nothing"). +Since this command has no output, there is no point in piping it with other commands. + +`print` may be used inside blocks of code (e.g.: hooks) to display text during execution without interfering with the pipeline."# } fn search_terms(&self) -> Vec<&str> { diff --git a/crates/nu-command/src/core_commands/echo.rs b/crates/nu-command/src/core_commands/echo.rs index 2b7d6c150..0f74310db 100644 --- a/crates/nu-command/src/core_commands/echo.rs +++ b/crates/nu-command/src/core_commands/echo.rs @@ -23,6 +23,10 @@ impl Command for Echo { .category(Category::Core) } + fn extra_usage(&self) -> &str { + "Unlike `print`, this command returns an actual value that will be passed to the next command of the pipeline." + } + fn run( &self, engine_state: &EngineState,