added ansi example (#2230)

* added ansi example

* added strcollect to example
This commit is contained in:
Darren Schroeder 2020-07-20 18:33:39 -05:00 committed by GitHub
parent b9278bdfe1
commit aaed9c4e8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -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",
)]),
},
]
}

View file

@ -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 {