Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3ff6181
code dump
Crypto-Darth Apr 2, 2025
c4a06b0
fix : new checks + working stage
Crypto-Darth Apr 3, 2025
34202b2
minor fixes + duplicates check
Crypto-Darth Apr 3, 2025
6861958
fix : add check for incorrect chained commands
Crypto-Darth Apr 4, 2025
4d55911
add : Chained Argument matching for -xtype
Crypto-Darth Apr 5, 2025
c67cf31
add: test
Crypto-Darth Apr 5, 2025
6800fb7
Merge branch 'uutils:main' into type_matcher
Crypto-Darth Apr 5, 2025
84bff99
cargo fmt
Crypto-Darth Apr 5, 2025
28fc28e
Add : more tests + old test fix
Crypto-Darth Apr 5, 2025
7e8fa39
refactor : move common code to function
Crypto-Darth Apr 5, 2025
9dfbcf7
Merge branch 'uutils:main' into type_matcher
Crypto-Darth Apr 6, 2025
e173233
fix : convert match to if/else
Crypto-Darth Apr 6, 2025
27c4ad6
Improve : Testcase for xtype
Crypto-Darth Apr 6, 2025
9406aaa
cargo clippy fix
Crypto-Darth Apr 6, 2025
303fd78
update : testcase
Crypto-Darth Apr 6, 2025
87e018b
fix : error handling
Crypto-Darth Apr 7, 2025
dcaee19
fix : use single type
Crypto-Darth Apr 8, 2025
8bb979e
add: basic tests on binary level
Crypto-Darth Apr 8, 2025
3295adc
Add : -xtype tests
Crypto-Darth Apr 8, 2025
295dc0b
refactor : use single type without Option<>
Crypto-Darth Apr 8, 2025
b2cc194
fix : use better search logic
Crypto-Darth Apr 9, 2025
2ef8685
refactor : use HashSet<> instead of Vec<>
Crypto-Darth Apr 9, 2025
66f3e37
remove : unnecessary hashmap usage
Crypto-Darth Apr 9, 2025
4c221fc
Update src/find/matchers/type_matcher.rs
Crypto-Darth Apr 9, 2025
113b5d9
change: variable name
Crypto-Darth Apr 9, 2025
d55873b
remove: type and replace with HashSet<FileType>
Crypto-Darth Apr 9, 2025
7ceaabd
Merge branch 'uutils:main' into type_matcher
Crypto-Darth Apr 12, 2025
8ffc30d
remove: trimming
Crypto-Darth Apr 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
code dump
  • Loading branch information
Crypto-Darth committed Apr 2, 2025
commit 3ff6181c46563f0757e864dbb25f92c86acc4ac6
23 changes: 20 additions & 3 deletions src/find/matchers/type_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use super::{FileType, Follow, Matcher, MatcherIO, WalkEntry};

/// This matcher checks the type of the file.
pub struct TypeMatcher {
file_type: FileType,
file_type: Option<FileType>,
chained_file_types: Option<Vec<FileType>>
}

fn parse(type_string: &str) -> Result<FileType, Box<dyn Error>> {
Expand Down Expand Up @@ -39,8 +40,24 @@ fn parse(type_string: &str) -> Result<FileType, Box<dyn Error>> {

impl TypeMatcher {
pub fn new(type_string: &str) -> Result<Self, Box<dyn Error>> {
let file_type = parse(type_string)?;
Ok(Self { file_type })
if type_string.contains(","){
let chained_type_list = type_string
.split(',')
.map(|s| {
if s.is_empty() {
Err(From::from("Empty type in comma-separated list"))
} else {
parse(s)
}
})
.collect::<Result<Vec<FileType>, _>>()?;
}else{
let single_file_type = parse(type_string)?;
}
Ok(Self {
file_type:Some(),
chained_file_types:None
})
}
}

Expand Down