bat/examples/simple.rs

23 lines
603 B
Rust
Raw Normal View History

2020-03-21 21:45:03 +01:00
/// A simple program that prints its own source code using the bat library
2019-10-20 21:53:34 +02:00
use bat::{
config::{Config, InputFile, OrdinaryFile},
2020-03-21 21:15:12 +01:00
Controller, HighlightingAssets,
2019-10-20 21:53:34 +02:00
};
2020-03-21 21:45:03 +01:00
use std::ffi::OsStr;
2019-10-20 21:53:34 +02:00
fn main() {
2020-03-21 21:45:03 +01:00
let path_to_this_file = OsStr::new(file!());
2019-10-20 21:53:34 +02:00
let config = Config {
2020-04-11 19:17:36 +02:00
files: vec![InputFile::Ordinary(OrdinaryFile::from_path(
path_to_this_file,
))],
2019-10-20 21:53:34 +02:00
colored_output: true,
true_color: true,
..Default::default()
};
let assets = HighlightingAssets::from_binary();
2019-10-20 21:53:34 +02:00
Controller::new(&config, &assets).run().expect("no errors");
}