bat/examples/simple.rs

36 lines
963 B
Rust
Raw Normal View History

2019-10-20 19:53:34 +00:00
use bat::{
assets::HighlightingAssets,
2020-03-21 18:40:43 +00:00
config::Config,
2019-10-20 19:53:34 +00:00
controller::Controller,
inputfile::InputFile,
style::{OutputComponent, OutputComponents},
};
use console::Term;
use std::process;
fn main() {
let files = std::env::args_os().skip(1).collect::<Vec<_>>();
2019-10-20 19:53:34 +00:00
if files.is_empty() {
eprintln!("No input files specified");
process::exit(1);
}
let config = Config {
term_width: Term::stdout().size().1 as usize,
colored_output: true,
true_color: true,
output_components: OutputComponents::new(&[
OutputComponent::Header,
OutputComponent::Grid,
OutputComponent::Numbers,
]),
files: files.iter().map(|file| InputFile::Ordinary(file)).collect(),
theme: "1337".into(),
..Default::default()
};
let assets = HighlightingAssets::from_binary();
2019-10-20 19:53:34 +00:00
Controller::new(&config, &assets).run().expect("no errors");
}