mirror of
https://github.com/nushell/nushell
synced 2025-01-01 07:48:53 +00:00
added ansi example (#2230)
* added ansi example * added strcollect to example
This commit is contained in:
parent
b9278bdfe1
commit
aaed9c4e8a
2 changed files with 10 additions and 1 deletions
|
@ -40,6 +40,14 @@ impl WholeStreamCommand for Ansi {
|
||||||
example: r#"ansi reset"#,
|
example: r#"ansi reset"#,
|
||||||
result: Some(vec![Value::from("\u{1b}[0m")]),
|
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",
|
||||||
|
)]),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use nu_protocol::hir::ClassifiedBlock;
|
||||||
use nu_protocol::{ShellTypeName, Value};
|
use nu_protocol::{ShellTypeName, Value};
|
||||||
|
|
||||||
use crate::commands::classified::block::run_block;
|
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::context::Context;
|
||||||
use crate::stream::InputStream;
|
use crate::stream::InputStream;
|
||||||
use crate::WholeStreamCommand;
|
use crate::WholeStreamCommand;
|
||||||
|
@ -19,6 +19,7 @@ pub fn test(cmd: impl WholeStreamCommand + 'static) {
|
||||||
whole_stream_command(Echo {}),
|
whole_stream_command(Echo {}),
|
||||||
whole_stream_command(BuildString {}),
|
whole_stream_command(BuildString {}),
|
||||||
whole_stream_command(cmd),
|
whole_stream_command(cmd),
|
||||||
|
whole_stream_command(StrCollect),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
for example in examples {
|
for example in examples {
|
||||||
|
|
Loading…
Reference in a new issue