mmv 0.1.0

lib to mass move files with template names
Documentation
#![forbid(unsafe_code)]

use crate::error_handler::Error;
use crate::matches::ParsedFileName;
use crate::input_parser::ParsedPattern;

pub fn match_pattern_with_file_names(
    pattern: &ParsedPattern,
    file_names: &Vec<String>,
) -> Result<Vec<ParsedFileName>, Error> {
    let mut matching_files = Vec::<ParsedFileName>::new();

    for file_name in file_names {
        match pattern.match_to_pattern(file_name) {
            Err(_) => continue,
            Ok(fragments) => matching_files.push(ParsedFileName::new(file_name, fragments)),
        }
    }

    match matching_files.is_empty() {
        true => Err(Error::NoMatchingFilesFound),
        false => Ok(matching_files),
    }
}