on 59f2b30 help sign in
bat/examples/using_controller.rs
32 lines 876 B history raw
1use bat::{
2 assets::HighlightingAssets,
3 controller::Controller,
4 inputfile::InputFile,
5 style::{OutputComponent, OutputComponents},
6 Config,
7};
8use std::collections::HashSet;
10fn main() {
11 let assets = HighlightingAssets::new();
12 let mut config = Config {
13 term_width: 100, // must be greater than 13 to enable style=numbers
14 colored_output: true,
15 true_color: true,
16 output_components: OutputComponents(with_header()),
17 ..Default::default()
18 };
19 let mut add_file = |file: &'static str| config.files.push(InputFile::Ordinary(file));
21 add_file("Cargo.toml");
23 let print = || Controller::new(&config, &assets).run();
24 print().expect("no error");
27fn with_header() -> HashSet<OutputComponent> {
28 [OutputComponent::Header, OutputComponent::Grid]
29 .iter()
30 .cloned()
31 .collect()