1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-02 19:32:25 +01:00

Add new --style called header-filesize and display it by default (#1988)

Also rename `header` to `header-filename`.

Related to #1701
This commit is contained in:
Mahdi Dibaiee
2022-02-07 19:48:57 +00:00
committed by GitHub
parent f3f8194932
commit 312c8ef01f
111 changed files with 302 additions and 42 deletions

View File

@@ -1,4 +1,5 @@
use std::convert::TryFrom;
use std::fs;
use std::fs::File;
use std::io::{self, BufRead, BufReader, Read};
use std::path::{Path, PathBuf};
@@ -87,6 +88,7 @@ impl<'a> InputKind<'a> {
#[derive(Clone, Default)]
pub(crate) struct InputMetadata {
pub(crate) user_provided_name: Option<PathBuf>,
pub(crate) size: Option<u64>,
}
pub struct Input<'a> {
@@ -130,9 +132,14 @@ impl<'a> Input<'a> {
fn _ordinary_file(path: &Path) -> Self {
let kind = InputKind::OrdinaryFile(path.to_path_buf());
let metadata = InputMetadata {
size: fs::metadata(path).map(|m| m.len()).ok(),
..InputMetadata::default()
};
Input {
description: kind.description(),
metadata: InputMetadata::default(),
metadata,
kind,
}
}