Changed wild to glob
This commit is contained in:
parent
4ae64c568b
commit
22e90479d8
3 changed files with 29 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -471,6 +471,7 @@ dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"filetime",
|
"filetime",
|
||||||
|
"glob",
|
||||||
"image",
|
"image",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"libdeflater",
|
"libdeflater",
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@ version = "4.3.8"
|
||||||
optional = true
|
optional = true
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
|
|
||||||
|
[dependencies.glob]
|
||||||
|
optional = true
|
||||||
|
version = "0.3.1"
|
||||||
|
|
||||||
[dependencies.image]
|
[dependencies.image]
|
||||||
optional = true
|
optional = true
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
@ -66,7 +70,7 @@ version = "0.24.6"
|
||||||
rustc_version = "0.4.0"
|
rustc_version = "0.4.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
binary = ["clap", "wild", "stderrlog"]
|
binary = ["clap", "wild", "glob", "stderrlog"]
|
||||||
default = ["binary", "filetime", "parallel", "zopfli"]
|
default = ["binary", "filetime", "parallel", "zopfli"]
|
||||||
parallel = ["rayon", "indexmap/rayon", "crossbeam-channel"]
|
parallel = ["rayon", "indexmap/rayon", "crossbeam-channel"]
|
||||||
freestanding = ["libdeflater/freestanding"]
|
freestanding = ["libdeflater/freestanding"]
|
||||||
|
|
|
||||||
24
src/main.rs
24
src/main.rs
|
|
@ -295,7 +295,7 @@ Heuristic filter selection strategies:
|
||||||
8 => BigEnt Highest Shannon entropy of bigrams
|
8 => BigEnt Highest Shannon entropy of bigrams
|
||||||
9 => Brute Smallest compressed size (slow)",
|
9 => Brute Smallest compressed size (slow)",
|
||||||
)
|
)
|
||||||
.get_matches_from(wild::args());
|
.get_matches();
|
||||||
|
|
||||||
let (out_file, out_dir, opts) = match parse_opts_into_struct(&matches) {
|
let (out_file, out_dir, opts) = match parse_opts_into_struct(&matches) {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
|
|
@ -306,6 +306,14 @@ Heuristic filter selection strategies:
|
||||||
};
|
};
|
||||||
|
|
||||||
let files = collect_files(
|
let files = collect_files(
|
||||||
|
#[cfg(windows)]
|
||||||
|
matches
|
||||||
|
.get_many::<PathBuf>("files")
|
||||||
|
.unwrap()
|
||||||
|
.cloned()
|
||||||
|
.flat_map(apply_glob_pattern)
|
||||||
|
.collect(),
|
||||||
|
#[cfg(not(windows))]
|
||||||
matches
|
matches
|
||||||
.get_many::<PathBuf>("files")
|
.get_many::<PathBuf>("files")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
@ -383,6 +391,20 @@ fn collect_files(
|
||||||
in_out_pairs
|
in_out_pairs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
fn apply_glob_pattern(path: PathBuf) -> Vec<PathBuf> {
|
||||||
|
let mut paths = vec![];
|
||||||
|
let input_path = path.to_str().unwrap();
|
||||||
|
glob::glob(input_path)
|
||||||
|
.expect("Failed to read glob pattern")
|
||||||
|
.for_each(|path| {
|
||||||
|
let path = path.unwrap();
|
||||||
|
paths.push(path)
|
||||||
|
});
|
||||||
|
|
||||||
|
paths
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_opts_into_struct(
|
fn parse_opts_into_struct(
|
||||||
matches: &ArgMatches,
|
matches: &ArgMatches,
|
||||||
) -> Result<(OutFile, Option<PathBuf>, Options), String> {
|
) -> Result<(OutFile, Option<PathBuf>, Options), String> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue