bat/examples/inputs.rs

20 lines
626 B
Rust
Raw Normal View History

2020-05-16 22:16:51 +00:00
/// 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!'")
2020-05-27 22:26:34 +00:00
.name("embedded.sh") // Dummy name provided to detect the syntax.
.kind("Embedded")
.title("An embedded shell script."),
2020-05-16 22:16:51 +00:00
Input::from_stdin().title("Standard Input").kind("FD"),
])
.print()
.unwrap();
}