diff --git a/Cargo.lock b/Cargo.lock index f3d30e1..74ffa4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", ] diff --git a/src/parameters.rs b/src/parameters.rs index 00d047a..d68bdcf 100644 --- a/src/parameters.rs +++ b/src/parameters.rs @@ -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>, /// 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>, /// 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 {