Browse Source

Major release of v0.1.6

This mainly gets a working, clean only if last modified and last accessed over X days

It was found that we had a function with a parameter of days, and a local variable called days... thus the parameter was being unused/destroyed/eaten
david 1 month ago
parent
commit
1e8ace108b
5 changed files with 17 additions and 10 deletions
  1. 4 1
      CHANGELOG
  2. 1 1
      Cargo.lock
  3. 1 1
      Cargo.toml
  4. 3 1
      README.md
  5. 8 6
      src/main.rs

+ 4 - 1
CHANGELOG

@@ -1,4 +1,7 @@
-v0.1.5 => Latest
+v0.1.6 => Latest
+    Fixed CLI bug where we were overwriting the days to consider last modified
+    and last accessed
+v0.1.5
     Added clap CLI
 v0.1.4
     Added a forced command line argument (clap is needed)

+ 1 - 1
Cargo.lock

@@ -142,7 +142,7 @@ dependencies = [
 
 [[package]]
 name = "rustpan"
-version = "0.1.5"
+version = "0.1.6"
 dependencies = [
  "anyhow",
  "clap",

+ 1 - 1
Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "rustpan"
-version = "0.1.5"
+version = "0.1.6"
 edition = "2021"
 
 [dependencies]

+ 3 - 1
README.md

@@ -2,7 +2,7 @@
 
 It's not a dust pan, it's a rust pan. (A cargo cleaner)
 
-> See `CHANGELOG` for info on [v0.1.2](https://git.red-green.com/david/rustpan/src/v0.1.2)
+> See `CHANGELOG` for info on [v0.1.6](https://git.red-green.com/david/rustpan/src/v0.1.6)
 
 ## Installation
 
@@ -14,6 +14,8 @@ It's a simple rust crate that goes thru the current working directory finding cr
 
 As of [v0.1.1](https://git.red-green.com/david/rustpan/src/v0.1.1) it also supports nested crates... (this feature is further enhanced in [v0.1.2](https://git.red-green.com/david/rustpan/src/v0.1.2))
 
+As of [v0.1.6](https://git.red-green.com/david/rustpan/src/v0.1.6) it also only cleans after last modified and/or last accessed exceed a certain X days (This feature first arrived in v0.1.[3](https://git.red-green.com/david/rustpan/src/v0.1.3) and was improved thru v0.1.[4](https://git.red-green.com/david/rustpan/src/v0.1.4), v0.1.[5](https://git.red-green.com/david/rustpan/src/v0.1.5) and finalized in v0.1.[6](https://git.red-green.com/david/rustpan/src/v0.1.6))
+
 ```
 # E.G.
 dev/rust/major_project/

+ 8 - 6
src/main.rs

@@ -2,17 +2,19 @@ use std::{env, fs, path::PathBuf, process, time::SystemTime};
 use anyhow::Result as anyResult;
 use clap::Parser;
 
-#[derive(Parser)]
+const SECS_IN_DAY: u64 = 86400;
+
+#[derive(Parser, Debug)]
 #[command(version = "0.1.5", about = "It's not a dust pan, it's a rust pan. (A cargo cleaner)", long_about = None)]
 struct Args {
     #[arg(short='v', long="verbose")]
-    /// Print directory even if it's not being cleaned
+    /// Print extra information
     verbose: bool,
     #[arg(short='d', long="days", default_value_t=30)]
     /// Days since last modified and/or last accessed
     days: u32,
     #[arg(short='f', long="force")]
-    /// Clean the directory, ignoring days since last modified and/or last accessed
+    /// Clean the directory, ignoring last modified and/or last accessed
     force: bool,
 }
 
@@ -90,10 +92,10 @@ fn clean_in_dir(path: PathBuf, verbose: bool, forced: bool, days: u64) -> anyRes
                     } else {
                         el = access.elapsed()?.as_secs();
                     }
-                    let days = el / 86400;
-                    if days < days {
+                    let d = el / SECS_IN_DAY;
+                    if d < days {
                         if verbose {
-                            println!(" => {} (dirty, {} days)", p.display(), days);
+                            println!(" => {} (dirty, {} days)", p.display(), d);
                         }
                         continue;
                     }