on master help sign in
Update examples
3eb704eEthan P
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 @@
1/// A program that serializes a Rust structure to YAML and pretty-prints the result
1/// A program that serializes a Rust structure to YAML and pretty-prints the result
2−use bat::PrettyPrinter;
2+use bat::{Input, PrettyPrinter};
3use serde::Serialize;
3use serde::Serialize;
4
4
5#[derive(Serialize)]
5#[derive(Serialize)]
@@ -29,7 +29,7 @@ fn main() {
29 .line_numbers(true)
29 .line_numbers(true)
30 .grid(true)
30 .grid(true)
31 .header(true)
31 .header(true)
32− .input_from_bytes_with_name(&bytes, "person.yaml")
32+ .input(Input::from_bytes(&bytes).name("person.yaml").kind("File"))
33 .print()
33 .print()
34 .unwrap();
34 .unwrap();
35}
35}