1
0
mirror of https://github.com/sharkdp/bat synced 2026-07-17 16:03:19 +00:00
Files
sharkdp--bat/src/bin/bat/input.rs
T
Yuri Astrakhan 503c50b1ec chore: address all cargo clippy lints
* also do a bit of a doc cleanup for the `load_from_folder` fn
2025-08-19 05:22:47 +02:00

21 lines
567 B
Rust

use bat::input::Input;
use std::path::Path;
pub fn new_file_input<'a>(file: &'a Path, name: Option<&'a Path>) -> Input<'a> {
named(Input::ordinary_file(file), name.or(Some(file)))
}
pub fn new_stdin_input(name: Option<&Path>) -> Input<'_> {
named(Input::stdin(), name)
}
fn named<'a>(input: Input<'a>, name: Option<&Path>) -> Input<'a> {
if let Some(provided_name) = name {
let mut input = input.with_name(Some(provided_name));
input.description_mut().set_kind(Some("File".to_owned()));
input
} else {
input
}
}