summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorsharkdp <davidpeter@web.de>2020-04-21 20:06:09 +0200
committerDavid Peter <sharkdp@users.noreply.github.com>2020-04-22 23:55:28 +0200
commit057e4eced1a74972dd5aef90c2c054acb7963c60 (patch)
tree74f795a973eb69c4ec8448e86aa28789e640c45e /examples
parent27974616bfe7ec0c132fc259fdce1b471c99c93e (diff)
Large refactoring towards a better builder structure
Diffstat (limited to 'examples')
-rw-r--r--examples/cat.rs35
1 files changed, 8 insertions, 27 deletions
diff --git a/examples/cat.rs b/examples/cat.rs
index c98270bb..4575add0 100644
--- a/examples/cat.rs
+++ b/examples/cat.rs
@@ -1,36 +1,17 @@
/// A very simple colorized `cat` clone, using `bat` as a library.
/// See `src/bin/bat` for the full `bat` application.
-use bat::{
- config::{Config, InputFile, OrdinaryFile, StyleComponent, StyleComponents},
- Controller, HighlightingAssets,
-};
+use bat::{PrettyPrinter, StyleComponent, StyleComponents};
use console::Term;
-use std::process;
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 config = Config {
- term_width: Term::stdout().size().1 as usize,
- colored_output: true,
- true_color: true,
- style_components: StyleComponents::new(&[
+ PrettyPrinter::new()
+ .term_width(Term::stdout().size().1 as usize)
+ .style_components(StyleComponents::new(&[
StyleComponent::Header,
StyleComponent::Grid,
StyleComponent::Numbers,
- ]),
- files: files
- .iter()
- .map(|file| InputFile::Ordinary(OrdinaryFile::from_path(file)))
- .collect(),
- ..Default::default()
- };
- let assets = HighlightingAssets::from_binary();
-
- Controller::new(&config, &assets).run().expect("no errors");
+ ]))
+ .files(std::env::args_os().skip(1))
+ .run()
+ .expect("no errors");
}