From aaed9c4e8aafb6155e8b316b320599ac6e6f60ac Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Mon, 20 Jul 2020 18:33:39 -0500 Subject: [PATCH] added ansi example (#2230) * added ansi example * added strcollect to example --- crates/nu-cli/src/commands/ansi.rs | 8 ++++++++ crates/nu-cli/src/examples.rs | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/nu-cli/src/commands/ansi.rs b/crates/nu-cli/src/commands/ansi.rs index 302710e344..6d105b0225 100644 --- a/crates/nu-cli/src/commands/ansi.rs +++ b/crates/nu-cli/src/commands/ansi.rs @@ -40,6 +40,14 @@ impl WholeStreamCommand for Ansi { example: r#"ansi reset"#, result: Some(vec![Value::from("\u{1b}[0m")]), }, + Example { + description: + "Use ansi to color text (rb = red bold, gb = green bold, pb = purple bold)", + example: r#"echo [$(ansi rb) Hello " " $(ansi gb) Nu " " $(ansi pb) World] | str collect"#, + result: Some(vec![Value::from( + "\u{1b}[1;31mHello \u{1b}[1;32mNu \u{1b}[1;35mWorld", + )]), + }, ] } diff --git a/crates/nu-cli/src/examples.rs b/crates/nu-cli/src/examples.rs index bb81029b25..916606aafa 100644 --- a/crates/nu-cli/src/examples.rs +++ b/crates/nu-cli/src/examples.rs @@ -6,7 +6,7 @@ use nu_protocol::hir::ClassifiedBlock; use nu_protocol::{ShellTypeName, Value}; use crate::commands::classified::block::run_block; -use crate::commands::{whole_stream_command, BuildString, Echo}; +use crate::commands::{whole_stream_command, BuildString, Echo, StrCollect}; use crate::context::Context; use crate::stream::InputStream; use crate::WholeStreamCommand; @@ -19,6 +19,7 @@ pub fn test(cmd: impl WholeStreamCommand + 'static) { whole_stream_command(Echo {}), whole_stream_command(BuildString {}), whole_stream_command(cmd), + whole_stream_command(StrCollect), ]); for example in examples {