rename `dirs` parameter to `dir`

This commit is contained in:
Lynne Megido 2021-05-08 10:10:51 +10:00
parent c3b5dbea35
commit 8341c4aaf7
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
3 changed files with 8 additions and 12 deletions

View File

@ -76,7 +76,7 @@ fn main() {
trace!("Initialise mimetype database");
init_db();
debug!("Iterating directory: {:?}", args.dirs);
debug!("Iterating directory: {:?}", args.dir);
let extensions = args.extensions();
let excludes = args.excluded_extensions();
@ -89,12 +89,7 @@ fn main() {
debug!("Checking files regardless of extensions");
}
let entries = scan_directory(
&args.dirs,
extensions.as_ref(),
excludes.as_ref(),
&args.get_scan_opts(),
);
let entries = scan_directory(&args.dir, extensions.as_ref(), excludes.as_ref(), &args.get_scan_opts());
if entries.is_none() {
// no need to log anything for fatal errors - fif will already have printed something obvious like

View File

@ -115,9 +115,8 @@ pub struct Parameters {
pub quiet: u8,
/// The directory to process.
// TODO: right now this can only take a single directory - should this be improved?
#[clap(name = "DIR", default_value = ".", parse(from_os_str))]
pub dirs: PathBuf,
pub dir: PathBuf,
}
fn lowercase_exts(exts: &str) -> Result<(), String> {

View File

@ -70,7 +70,9 @@ fn recommend_ext() {
assert!(mime_extension_lookup(IMAGE_JPEG.essence_str().into())
.unwrap()
.contains(&String::from("jpg")));
assert!(mime_extension_lookup(IMAGE_PNG.essence_str().into()).unwrap().contains(&String::from("png")));
assert!(mime_extension_lookup(IMAGE_PNG.essence_str().into())
.unwrap()
.contains(&String::from("png")));
assert!(mime_extension_lookup(APPLICATION_PDF.essence_str().into())
.unwrap()
.contains(&String::from("pdf")));
@ -116,7 +118,7 @@ fn simple_directory() {
follow_symlinks: false,
};
let entries = scan_directory(&dir.path().to_path_buf(), None, None, &scan_opts).expect("Directory scan failed.");
let entries = scan_directory(dir.path(), None, None, &scan_opts).expect("Directory scan failed.");
assert_eq!(entries.len(), files.len());
@ -210,7 +212,7 @@ fn argument_parsing() {
fn positional_args() {
for flag in &["-x", "-e", "-X", "-E"] {
assert_eq!(
Parameters::parse_from(vec!["fif", flag, "images", "directory"]).dirs,
Parameters::parse_from(vec!["fif", flag, "images", "directory"]).dir,
PathBuf::from("directory")
)
}