mirror of
https://github.com/sharkdp/bat.git
synced 2025-08-09 07:45:09 +02:00
Add an even simple example
This commit is contained in:
@ -1,29 +1,18 @@
|
||||
/// A simple program that prints its own source code using the bat library
|
||||
|
||||
use bat::{
|
||||
config::{Config, InputFile, StyleComponent, StyleComponents},
|
||||
config::{Config, InputFile},
|
||||
Controller, HighlightingAssets,
|
||||
};
|
||||
use console::Term;
|
||||
use std::process;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
fn main() {
|
||||
let files = std::env::args_os().skip(1).collect::<Vec<_>>();
|
||||
|
||||
if files.is_empty() {
|
||||
eprintln!("No input files specified");
|
||||
process::exit(1);
|
||||
}
|
||||
let path_to_this_file = OsStr::new(file!());
|
||||
|
||||
let config = Config {
|
||||
term_width: Term::stdout().size().1 as usize,
|
||||
files: vec![InputFile::Ordinary(path_to_this_file)],
|
||||
colored_output: true,
|
||||
true_color: true,
|
||||
style_components: StyleComponents::new(&[
|
||||
StyleComponent::Header,
|
||||
StyleComponent::Grid,
|
||||
StyleComponent::Numbers,
|
||||
]),
|
||||
files: files.iter().map(|file| InputFile::Ordinary(file)).collect(),
|
||||
theme: "1337".into(),
|
||||
..Default::default()
|
||||
};
|
||||
let assets = HighlightingAssets::from_binary();
|
||||
|
Reference in New Issue
Block a user