diff options
author | sharkdp <davidpeter@web.de> | 2020-04-22 21:16:40 +0200 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-04-22 23:55:28 +0200 |
commit | 74d4377ed28c4350807c967597ba5081f2ce7a74 (patch) | |
tree | f77f33c2cd4dc3af2f215b45504a43445357e836 /examples | |
parent | 6a124591df487d0872a0d4963907a69f77fe68ee (diff) |
Add advanced example
Diffstat (limited to 'examples')
-rw-r--r-- | examples/advanced.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/advanced.rs b/examples/advanced.rs new file mode 100644 index 00000000..1c4685e7 --- /dev/null +++ b/examples/advanced.rs @@ -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"); +} |