on master help sign in
Update examples
commit3eb704e0169e3f2d56d44656a2d3c9579e6c9e93 authorEthan P <eth-p+git@hidden.email> dateSat 16 May 2020, 15:16 (6 years ago) parent0f06d3b
2 files changed+21−2
examples/inputs.rs+19 examples/yaml.rs+2−2
examples/inputs.rsnew file+19
@@ -0,0 +1,19 @@
1+/// A small demonstration of the Input API.
2+/// This prints embedded bytes with a custom header and then reads from STDIN.
3+use bat::{Input, PrettyPrinter};
4+
5+fn main() {
6+ PrettyPrinter::new()
7+ .header(true)
8+ .grid(true)
9+ .line_numbers(true)
10+ .inputs(vec![
11+ Input::from_bytes(b"echo 'Hello World!'")
12+ .name("embedded.sh")
13+ .title("An embedded shell script.")
14+ .kind("Embedded"),
15+ Input::from_stdin().title("Standard Input").kind("FD"),
16+ ])
17+ .print()
18+ .unwrap();
19+}
examples/yaml.rs+2−2
@@ -1,5 +1,5 @@
11/// A program that serializes a Rust structure to YAML and pretty-prints the result
2−use bat::PrettyPrinter;
2+use bat::{Input, PrettyPrinter};
33use serde::Serialize;
44
55#[derive(Serialize)]
@@ -29,7 +29,7 @@ fn main() {
2929 .line_numbers(true)
3030 .grid(true)
3131 .header(true)
32− .input_from_bytes_with_name(&bytes, "person.yaml")
32+ .input(Input::from_bytes(&bytes).name("person.yaml").kind("File"))
3333 .print()
3434 .unwrap();
3535}