diff options
author | Ethan P <eth-p+git@hidden.email> | 2020-05-16 15:16:51 -0700 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-05-29 22:13:10 +0200 |
commit | 3eb704e0169e3f2d56d44656a2d3c9579e6c9e93 (patch) | |
tree | 1e2469cf00ced7380671822ee5019afd4a95f100 /examples | |
parent | 0f06d3b90da3ed0d89bc4722c8cbc83ec1b8e234 (diff) |
Update examples
Diffstat (limited to 'examples')
-rw-r--r-- | examples/inputs.rs | 19 | ||||
-rw-r--r-- | examples/yaml.rs | 4 |
2 files changed, 21 insertions, 2 deletions
diff --git a/examples/inputs.rs b/examples/inputs.rs new file mode 100644 index 00000000..be4e9e3b --- /dev/null +++ b/examples/inputs.rs @@ -0,0 +1,19 @@ +/// A small demonstration of the Input API. +/// This prints embedded bytes with a custom header and then reads from STDIN. +use bat::{Input, PrettyPrinter}; + +fn main() { + PrettyPrinter::new() + .header(true) + .grid(true) + .line_numbers(true) + .inputs(vec![ + Input::from_bytes(b"echo 'Hello World!'") + .name("embedded.sh") + .title("An embedded shell script.") + .kind("Embedded"), + Input::from_stdin().title("Standard Input").kind("FD"), + ]) + .print() + .unwrap(); +} diff --git a/examples/yaml.rs b/examples/yaml.rs index b504e424..78df2464 100644 --- a/examples/yaml.rs +++ b/examples/yaml.rs @@ -1,5 +1,5 @@ /// A program that serializes a Rust structure to YAML and pretty-prints the result -use bat::PrettyPrinter; +use bat::{Input, PrettyPrinter}; use serde::Serialize; #[derive(Serialize)] @@ -29,7 +29,7 @@ fn main() { .line_numbers(true) .grid(true) .header(true) - .input_from_bytes_with_name(&bytes, "person.yaml") + .input(Input::from_bytes(&bytes).name("person.yaml").kind("File")) .print() .unwrap(); } |