on f5145ef help sign in
bat/examples/cat.rs
33 lines 997 B history raw
1/// A very simple colorized `cat` clone, using `bat` as a library.
2/// See `src/bin/bat` for the full `bat` application.
3use bat::{
4 config::{Config, InputFile, StyleComponent, StyleComponents},
5 Controller, HighlightingAssets,
6};
7use console::Term;
8use std::process;
10fn main() {
11 let files = std::env::args_os().skip(1).collect::<Vec<_>>();
13 if files.is_empty() {
14 eprintln!("No input files specified");
15 process::exit(1);
16 }
18 let config = Config {
19 term_width: Term::stdout().size().1 as usize,
20 colored_output: true,
21 true_color: true,
22 style_components: StyleComponents::new(&[
23 StyleComponent::Header,
24 StyleComponent::Grid,
25 StyleComponent::Numbers,
26 ]),
27 files: files.iter().map(|file| InputFile::Ordinary(file)).collect(),
28 ..Default::default()
29 };
30 let assets = HighlightingAssets::from_binary();
32 Controller::new(&config, &assets).run().expect("no errors");