1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-03 11:52:26 +01:00

Support for ignored-suffix CLI arguments (#1892)

This commit is contained in:
Bojan Đurđević
2021-11-19 11:05:23 -05:00
committed by GitHub
parent 59d4cfb75c
commit d6ed5e6746
10 changed files with 191 additions and 55 deletions

View File

@@ -1,9 +1,12 @@
use std::path::Path;
use crate::error::Result;
use ignored_suffixes::IgnoredSuffixes;
use globset::{Candidate, GlobBuilder, GlobMatcher};
pub mod ignored_suffixes;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum MappingTarget<'a> {
/// For mapping a path to a specific syntax.
@@ -26,6 +29,7 @@ pub enum MappingTarget<'a> {
#[derive(Debug, Clone, Default)]
pub struct SyntaxMapping<'a> {
mappings: Vec<(GlobMatcher, MappingTarget<'a>)>,
pub(crate) ignored_suffixes: IgnoredSuffixes<'a>,
}
impl<'a> SyntaxMapping<'a> {
@@ -172,6 +176,10 @@ impl<'a> SyntaxMapping<'a> {
}
None
}
pub fn insert_ignored_suffix(&mut self, suffix: &'a str) {
self.ignored_suffixes.add_suffix(suffix);
}
}
#[test]