mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-22 15:53:29 +01:00
Update examples
This commit is contained in:
parent
49f4322054
commit
13f671b499
@ -1,10 +1,7 @@
|
|||||||
/// A program that prints its own source code using the bat library
|
/// A program that prints its own source code using the bat library
|
||||||
use bat::{LineRange, PrettyPrinter, WrappingMode};
|
use bat::{LineRange, PrettyPrinter, WrappingMode};
|
||||||
use std::ffi::OsStr;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let path_to_this_file = OsStr::new(file!());
|
|
||||||
|
|
||||||
PrettyPrinter::new()
|
PrettyPrinter::new()
|
||||||
.header(true)
|
.header(true)
|
||||||
.grid(true)
|
.grid(true)
|
||||||
@ -14,7 +11,7 @@ fn main() {
|
|||||||
.highlight(LineRange::new(line!() as usize, line!() as usize))
|
.highlight(LineRange::new(line!() as usize, line!() as usize))
|
||||||
.theme("1337")
|
.theme("1337")
|
||||||
.wrapping_mode(WrappingMode::Character)
|
.wrapping_mode(WrappingMode::Character)
|
||||||
.input_file(path_to_this_file)
|
.input_file(file!())
|
||||||
.print()
|
.print()
|
||||||
.expect("no errors");
|
.expect("no errors");
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
/// A simple program that prints its own source code using the bat library
|
/// A simple program that prints its own source code using the bat library
|
||||||
use bat::PrettyPrinter;
|
use bat::PrettyPrinter;
|
||||||
use std::ffi::OsStr;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let path_to_this_file = OsStr::new(file!());
|
|
||||||
|
|
||||||
PrettyPrinter::new()
|
PrettyPrinter::new()
|
||||||
.input_file(path_to_this_file)
|
.input_file(file!())
|
||||||
.print()
|
.print()
|
||||||
.expect("no errors");
|
.expect("no errors");
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ impl<'a> PrettyPrinter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add a file which should be pretty-printed
|
/// Add a file which should be pretty-printed
|
||||||
pub fn input_file(&mut self, path: &OsStr) -> &mut Self {
|
pub fn input_file(&mut self, path: impl AsRef<OsStr>) -> &mut Self {
|
||||||
self.inputs.push(Input::ordinary_file(path));
|
self.inputs.push(Input::ordinary_file(path.as_ref()));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user