mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-18 02:30:55 +01:00
Update examples
This commit is contained in:
parent
0f06d3b90d
commit
3eb704e016
19
examples/inputs.rs
Normal file
19
examples/inputs.rs
Normal file
@ -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();
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/// A program that serializes a Rust structure to YAML and pretty-prints the result
|
/// A program that serializes a Rust structure to YAML and pretty-prints the result
|
||||||
use bat::PrettyPrinter;
|
use bat::{Input, PrettyPrinter};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
@ -29,7 +29,7 @@ fn main() {
|
|||||||
.line_numbers(true)
|
.line_numbers(true)
|
||||||
.grid(true)
|
.grid(true)
|
||||||
.header(true)
|
.header(true)
|
||||||
.input_from_bytes_with_name(&bytes, "person.yaml")
|
.input(Input::from_bytes(&bytes).name("person.yaml").kind("File"))
|
||||||
.print()
|
.print()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user