Skip to content

Commit

Permalink
fix result message
Browse files Browse the repository at this point in the history
  • Loading branch information
craftgear committed Aug 14, 2024
1 parent 61a30a5 commit ce49d70
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "group_files_into_dirs"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
license = "MIT"
description = "Group files into directories based on keywords"
Expand Down
5 changes: 4 additions & 1 deletion src/workflow/dirs_as_keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ use crate::libs::keywords::extract_keywords;
use crate::libs::stdout::*;

use regex::Regex;
use std::collections::HashSet;
use std::fs;
use std::path::PathBuf;

pub fn execute(pathbuf: PathBuf, verbose: bool) -> Result<Vec<String>, Error> {
let mut moved_files = vec![];
let mut update_dirs: HashSet<String> = HashSet::new();

let dirnames = dirs_in_dir(&pathbuf)?;

Expand Down Expand Up @@ -53,6 +55,7 @@ pub fn execute(pathbuf: PathBuf, verbose: bool) -> Result<Vec<String>, Error> {
let result = fs::rename(&src, &dst);

if result.is_ok() {
update_dirs.insert(dirname.to_string());
let dst_string = dst.to_str().unwrap().to_string();
if verbose {
moved(filename.to_string(), dst_string.clone());
Expand All @@ -67,7 +70,7 @@ pub fn execute(pathbuf: PathBuf, verbose: bool) -> Result<Vec<String>, Error> {
}
}

print_result(dirnames.len(), Ok(moved_files.clone()));
print_result(update_dirs.len(), Ok(moved_files.clone()));

Ok(moved_files)
}
Expand Down

0 comments on commit ce49d70

Please sign in to comment.