logrotate 1.0.1

Cli tool for rotating / archiving files within specified directory.
Documentation
#![allow(unused_imports)]

use logrotate::{
    ArchiveType,
    archive_remove_truncate_file_bucketing,
    gather_files_from_directory,
    get_file_mtime_diff,
    dry_run_details,
    actual_run,
};

use anyhow::{Result};
use std::fmt::Debug;
use clap::Parser;

#[derive(Parser, Debug)]
#[command(author, version, about = "Rotate / Archive files within provided directory", long_about = None)]
struct Cli {
    /// Perform a dry run without making any changes
    /// Will output files marked for deletion, archival, and truncation
    #[arg(
        long,
        required = false,
    )]
    dry_run: bool,

    /// Archival method to use
    #[arg(
        short = 'a',
        long = "archive-method",
        value_enum,
        required = true,
    )]
    archive_method: ArchiveType,

    /// Directory to parse through
    #[arg(
        short = 'd',
        long = "directory",
        value_name = "DIRECTORY",
        required = true,
    )]
    directory: String,
    
    /// Number of days to keep archived files
    #[arg(
        short = 'k',
        long = "keep-days",
        value_name = "DAYS",
        default_value = "7",
        required = true,
    )]
    keep_days: u8,
}

#[cfg_attr(coverage_nightly, coverage(off))]
fn main() -> Result<()> {
    // Bug with Clap Derive - False error: 
    // E0599 No function or associated item 'parse' found in the current scope for struct Cli
    let args = <Cli as Parser>::parse();

    let arg_directory = args.directory;
    let arg_archive_method = args.archive_method;
    let arg_keep_days = args.keep_days;

    let file_list = gather_files_from_directory(&arg_directory)?;
    
    if args.dry_run {
        println!("Dry Run with the following args...\n\
         ARCHIVE METHOD: {:?}\n\
         DIRECTORY PATH: {:?}\n\
         KEEP FOR: {:?} DAYS", 
                 arg_archive_method, arg_directory, arg_keep_days
        );
        
        dry_run_details(file_list, arg_keep_days.into(), arg_archive_method);
    }
    else {
        actual_run(file_list, arg_keep_days.into(), arg_archive_method);
    }

    Ok(())
}