From f66d133420ac67299dfec02d52ee639363cc7cf9 Mon Sep 17 00:00:00 2001 From: Joshua Olaoye Date: Sat, 26 Oct 2024 12:06:49 -0500 Subject: [PATCH] chore: Update dependencies in Cargo.lock and Cargo.toml to ensure compatibility and stability --- file-shuffler/shuffler-in-rust/Cargo.lock | 120 +++++++++++++++++++++ file-shuffler/shuffler-in-rust/Cargo.toml | 3 +- file-shuffler/shuffler-in-rust/src/main.rs | 48 ++++++++- 3 files changed, 165 insertions(+), 6 deletions(-) diff --git a/file-shuffler/shuffler-in-rust/Cargo.lock b/file-shuffler/shuffler-in-rust/Cargo.lock index 9e9ad46..764ece6 100644 --- a/file-shuffler/shuffler-in-rust/Cargo.lock +++ b/file-shuffler/shuffler-in-rust/Cargo.lock @@ -17,6 +17,55 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +dependencies = [ + "anstyle", + "windows-sys", +] + [[package]] name = "autocfg" version = "1.4.0" @@ -70,6 +119,52 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "clap" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -99,6 +194,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "iana-time-zone" version = "0.1.61" @@ -122,6 +223,12 @@ dependencies = [ "cc", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "js-sys" version = "0.3.72" @@ -255,12 +362,19 @@ name = "shuffler-in-rust" version = "0.1.0" dependencies = [ "chrono", + "clap", "filetime", "rand", "terminal_size", "walkdir", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "syn" version = "2.0.85" @@ -288,6 +402,12 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "walkdir" version = "2.5.0" diff --git a/file-shuffler/shuffler-in-rust/Cargo.toml b/file-shuffler/shuffler-in-rust/Cargo.toml index 4ff92f2..b0ff470 100644 --- a/file-shuffler/shuffler-in-rust/Cargo.toml +++ b/file-shuffler/shuffler-in-rust/Cargo.toml @@ -8,4 +8,5 @@ walkdir = "2.3" rand = "0.8" filetime = "0.2" terminal_size = "0.1" -chrono = "0.4" \ No newline at end of file +chrono = "0.4" +clap = { version = "4.0", features = ["derive"] } \ No newline at end of file diff --git a/file-shuffler/shuffler-in-rust/src/main.rs b/file-shuffler/shuffler-in-rust/src/main.rs index 2930e1d..35395d0 100644 --- a/file-shuffler/shuffler-in-rust/src/main.rs +++ b/file-shuffler/shuffler-in-rust/src/main.rs @@ -1,4 +1,10 @@ -// use std::env; +/// File Shuffler +/// +/// This application shuffles files in a specified source directory at defined intervals. +/// +/// # Author +/// Joshua Olaoye + use std::fs; use std::io; use std::path::{Path, PathBuf}; @@ -12,7 +18,20 @@ use terminal_size::{Width, terminal_size}; use chrono::{DateTime, FixedOffset, TimeZone, LocalResult}; use clap::{Arg, Command}; -// Enum class for the time interval +/// Enum representing the time intervals for processing files. +/// +/// This enum defines the various intervals at which the application can process files in the specified source directory. +/// +/// # Variants +/// +/// - `Never`: +/// Indicates that the processing should occur only once and not repeat. +/// +/// - `EveryWeek`: +/// Indicates that the processing should occur once every week. +/// +/// - `Every30Seconds`: +/// Indicates that the processing should occur every 30 seconds. #[derive(Debug)] enum Interval { Never, @@ -20,6 +39,25 @@ enum Interval { Every30Seconds, } +/// Implementation of `FromStr` trait for `Interval` enum. +/// +/// This implementation allows for the creation of an `Interval` instance from a string representation. +/// +/// # Errors +/// +/// Returns an error if the input string does not match one of the defined interval options: +/// - "0" for `Interval::Never` +/// - "1" for `Interval::EveryWeek` +/// - "2" for `Interval::Every30Seconds` +/// +/// # Examples +/// +/// ``` +/// use std::str::FromStr; +/// +/// let interval = Interval::from_str("1").unwrap(); // Converts to `Interval::EveryWeek` +/// let invalid_interval = Interval::from_str("3"); // Returns an error +/// ``` impl FromStr for Interval { type Err = (); @@ -542,7 +580,7 @@ fn extract_datetime(local_result: LocalResult>) -> Option< /// The main entry point of the application. /// -/// This program processes files in a specified source directory at defined intervals. +/// This program shuffles files in a specified source directory at defined intervals. /// It can run continuously based on the specified interval or process the directory just once. /// /// # Usage @@ -596,10 +634,10 @@ fn extract_datetime(local_result: LocalResult>) -> Option< /// If the specified interval is not supported, the application will use `0` (never) by default. fn main() -> io::Result<()> { // Set up command-line argument parsing - let matches = Command::new("File Processor") + let matches = Command::new("File Shuffler") .version("1.0") .author("Your Name") - .about("Processes files in a directory") + .about("Shuffles files in a directory") .arg(Arg::new("source_directory") .help("The source directory to process") .required(true)