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 {