mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-25 01:03:46 +01:00
Add example to show new feature
This commit is contained in:
parent
b2c28cdddb
commit
33a89410d4
17
examples/buffer.rs
Normal file
17
examples/buffer.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
use bat::{assets::HighlightingAssets, config::Config, controller::Controller, Input};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut buffer = String::new();
|
||||||
|
let config = Config {
|
||||||
|
colored_output: true,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let assets = HighlightingAssets::from_binary();
|
||||||
|
let controller = Controller::new(&config, &assets);
|
||||||
|
let input = Input::from_file(file!());
|
||||||
|
controller
|
||||||
|
.run(vec![input.into()], Some(&mut buffer))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
println!("{buffer}");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user