DigitShield 0.1.6

A simple and quick password generator for enhanced security.
//!# DigitShield crate
//! A command-line password generator built with Rust, offering a swift and effortless solution for creating passwords of varying strengths. Cure your password creation woes with a single command!
use ansi_term::Color::Blue;
use clap::Parser;
use clipboard::ClipboardContext;
use clipboard::ClipboardProvider;
use colored::Colorize;
use DigitShield::*;

/// Command line arguments structure.
#[derive(Debug, Parser)]
#[command(version="1.0.0", author="Code0408", long_about = None)] // Metadata for the CLI tool
struct Args {
    #[arg(short = 'l', long = "len")]
    len: usize,

    #[arg(short = 'c', long = "complex")]
    complex: String,
}

/// Prints program information with styling.
fn print_infos() {
    println!(
        "{}",
        Blue.paint(
            r#"
            ___  _       _    _    ___  _    _       _    _
           | . \<_> ___ <_> _| |_ / __>| |_ <_> ___ | | _| |
           | | || |/ . || |  | |  \__ \| . || |/ ._>| |/ . |
           |___/|_|\_. ||_|  |_|  <___/|_|_||_|\___.|_|\___|
                   <___'
        "#
        )
    );
}

fn main() {
    print_infos();
    let args = Args::parse();

    let pwd = gen_password(args.len, args.complex.as_str());

    // Inform the user about the generated password and its default action (copy to clipboard)
    println!(
        "\n{}",
        "Below is the password you generated, which has been copied to the clipboard by default:\n"
            .underline()
    );
    println!("Your Password:\t{}", pwd.magenta());

    println!("\n\n");

    // Copy the generated password to the clipboard
    let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap();
    ctx.set_contents(pwd.to_owned()).unwrap();
}