reject lowercase exts bc they don't worky
This commit is contained in:
parent
32edcc0c92
commit
a60a19191a
2 changed files with 12 additions and 4 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -505,9 +505,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8270314b5ccceb518e7e578952f0b72b88222d02e8f77f5ecf7abbb673539041"
|
||||
checksum = "85dd92e586f7355c633911e11f77f3d12f04b1b1bd76a198bd34ae3af8341ef2"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
|
|
@ -48,7 +48,7 @@ pub struct Parameters {
|
|||
/// Only examine files with these extensions.
|
||||
/// Multiple extensions can be specified by either using the flag multiple times (`-e jpg -e png -e gif`), or by
|
||||
/// separating them with commas (`-e jpg,png,gif`).
|
||||
#[clap(short, long, use_delimiter = true, require_delimiter = true, value_name = "ext")]
|
||||
#[clap(short, long, use_delimiter = true, require_delimiter = true, value_name = "ext", validator = lowercase_exts)]
|
||||
pub exts: Option<Vec<StringType>>,
|
||||
|
||||
/// Use these preset lists of extensions as the search filter (comma-separated list).
|
||||
|
@ -59,7 +59,7 @@ pub struct Parameters {
|
|||
|
||||
/// Don't scan files with these extensions.
|
||||
/// This option takes precedence over extensions specified with `-e` or `-E`.
|
||||
#[clap(short = 'x', long, use_delimiter = true, require_delimiter = true, value_name = "ext")]
|
||||
#[clap(short = 'x', long, use_delimiter = true, require_delimiter = true, value_name = "ext", validator = lowercase_exts)]
|
||||
pub exclude: Option<Vec<StringType>>,
|
||||
|
||||
/// Exclude files using a preset list of extensions.
|
||||
|
@ -103,6 +103,14 @@ pub struct Parameters {
|
|||
pub dirs: PathBuf,
|
||||
}
|
||||
|
||||
fn lowercase_exts(exts: &str) -> Result<(), String> {
|
||||
// TODO: i would much rather accept uppercase exts and convert them to lowercase than just rejecting lowercase exts...
|
||||
if exts.to_lowercase() != exts {
|
||||
return Err(String::from("Supplied extensions must be lowercase"))
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Further options relating to scanning.
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub struct ScanOpts {
|
||||
|
|
Loading…
Reference in a new issue