Add advanced example

This commit is contained in:
sharkdp 2020-04-22 21:16:40 +02:00 committed by David Peter
parent 6a124591df
commit 74d4377ed2
1 changed files with 20 additions and 0 deletions

20
examples/advanced.rs Normal file
View File

@ -0,0 +1,20 @@
/// A program that prints its own source code using the bat library
use bat::{LineRange, PrettyPrinter, WrappingMode};
use std::ffi::OsStr;
fn main() {
let path_to_this_file = OsStr::new(file!());
PrettyPrinter::new()
.header(true)
.grid(true)
.line_numbers(true)
.use_italics(true)
// The following line will be highlighted in the output:
.highlight(LineRange::new(line!() as usize, line!() as usize))
.theme("1337")
.wrapping_mode(WrappingMode::Character)
.input_file(path_to_this_file)
.print()
.expect("no errors");
}