-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial implementation of types support
- Loading branch information
1 parent
93d7e14
commit a44ad46
Showing
3 changed files
with
78 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
pub mod args; | ||
pub mod format; | ||
pub mod stdstreams; | ||
pub mod types; | ||
pub mod types_default; | ||
pub mod walk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::types_default::DEFAULT_TYPES; | ||
|
||
use anyhow::Result; | ||
use ignore::types::{Types, TypesBuilder}; | ||
|
||
pub struct SizTypesBuilder { | ||
builder: TypesBuilder, | ||
} | ||
|
||
impl SizTypesBuilder { | ||
pub fn new() -> Self { | ||
Self { | ||
builder: TypesBuilder::new(), | ||
} | ||
} | ||
|
||
fn add_type_defaults(&mut self) { | ||
for &(names, exts) in DEFAULT_TYPES { | ||
for name in names { | ||
for ext in exts { | ||
self.builder.add(name, ext).expect("should never fail"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
pub fn filter_types(&mut self, types: &Vec<String>) -> Result<Types> { | ||
self.add_type_defaults(); | ||
for t in types { | ||
self.builder.select(&t); | ||
} | ||
Ok(self.builder.build()?) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters