databoxer 0.1.0-rc.1

Fast and easy to use CLI-based file encryption program
Documentation
//! Contains the code for the CLI command generation: arguments, flags, etc.

use clap::{command, Arg, ArgAction, Command};

pub fn get_command() -> Command {
    command!()
        /* BASE COMMAND */
        .arg(Arg::new("DEBUG")
            .short('d')
            .long("debug")
            .action(ArgAction::SetTrue)
            .help("Turns on extensive debug output information")
        )
        .arg(Arg::new("VERBOSE")
            .short('v')
            .long("verbose")
            .help("Use verbose output (extra information)")
            .action(ArgAction::SetTrue)
            .conflicts_with("QUIET")
        )
        .arg(Arg::new("QUIET")
            .short('q')
            .long("quiet")
            .help("Do not print any log messages")
            .action(ArgAction::SetTrue)
            .conflicts_with("VERBOSE")
        )
        /* BOX SUBCOMMAND */
        .subcommand(Command::new("box")
            .about("Encrypt specified files into a special file type")
            .arg(Arg::new("PATH")
                .help("Specify the path(s) to a file or directory for encryption. A file path encrypts the file and a directory path encrypts all files within")
                .default_value(".")
                .action(ArgAction::Append)
            )
            .arg(Arg::new("PASSWORD")
                .short('p')
                .long("password")
                .help("Specify the password used for authentication")
                .action(ArgAction::Set)
            )
            .arg(Arg::new("RECURSIVE")
                .short('R')
                .long("recursive")
                .help("Recursively encrypt directory")
                .action(ArgAction::SetTrue)
            )
            .arg(Arg::new("KEEP_NAME")
                .short('k')
                .long("keep-name")
                .help("Keep original file name for the encrypted file")
                .action(ArgAction::SetTrue)
                .conflicts_with("OUTPUT")
            )
            .arg(Arg::new("OUTPUT")
                .short('o')
                .long("output")
                .help("Specify a path for the output file. In case of multiple input paths, output paths will be specified in order of the input")
                .action(ArgAction::Append)
                .conflicts_with("KEEP_NAME")
            )
            .arg(Arg::new("SHOW_FULL_PATH")
                .short('f')
                .long("full")
                .help("Output the full relative path to the encrypted file")
                .action(ArgAction::SetTrue)
            )
            // .arg(Arg::new("overwrite") // TODO
            //     .short('w')
            //     .long("overwrite")
            //     .help("Automatically overwrite existing files without prompting the user")
            //     .action(ArgAction::SetTrue)
            // )
            // .arg(Arg::new("compression") // TODO
            //     .short('z')
            //     .long("compression")
            //     .help("Compresses the file(s) before encryption")
            //     .action(ArgAction::Set)
            //     .default_value("none")
            // )
            // .arg(Arg::new("exclude") // TODO
            //     .short('e')
            //     .long("exclude")
            //     .help("Exclude specific file patterns from being encrypted")
            //     .action(ArgAction::Set)
            // )
            // .arg(Arg::new("preserve-timestamp") // TODO
            //     .long("preserve-timestamp")
            //     .help("Retains the original file's timestamp when creating the encrypted file")
            //     .action(ArgAction::SetTrue)
            // )
        )
        /* UNBOX SUBCOMMAND */
        .subcommand(Command::new("unbox")
            .about("Decrypt specified files from a special file type")
            .arg(Arg::new("PATH")
                .help("Specify the path(s) to a file or directory for encryption. A file path encrypts the file and a directory path encrypts all files within")
                .default_value(".")
                .action(ArgAction::Append)
            )
            .arg(Arg::new("PASSWORD")
                .short('p')
                .long("password")
                .help("Specify the password used for authentication")
                .action(ArgAction::Set)
            )
            .arg(Arg::new("RECURSIVE")
                .short('R')
                .long("recursive")
                .help("Recursively decrypt directory")
                .action(ArgAction::SetTrue)
            )
            .arg(Arg::new("OUTPUT")
                .short('o')
                .long("output")
                .help("Specify a path for the output file. In case of multiple input paths, output paths will be specified in order of the input")
                .action(ArgAction::Append)
            )
            .arg(Arg::new("SHOW_FULL_PATH")
                .short('f')
                .long("full")
                .help("Output the full relative path to the decrypted file")
                .action(ArgAction::SetTrue)
            )
            // .arg(Arg::new("overwrite") // TODO
            //     .short('w')
            //     .long("overwrite")
            //     .help("Automatically overwrite existing files without prompting the user")
            //     .action(ArgAction::SetTrue)
            // )
            // .arg(Arg::new("check-integrity") // TODO
            //     .short('i')
            //     .long("check-integrity")
            //     .help("Validates the integrity of the decrypted file by comparing it with an original checksum (if available)")
            //     .action(ArgAction::SetTrue)
            // )
            // .arg(Arg::new("preserve-attributes") // TODO
            //     .long("preserve-attributes")
            //     .help("Preserves original file attributes (e.g., permissions, timestamps) when decrypting")
            //     .action(ArgAction::SetTrue)
            // )
        )
        .subcommand(Command::new("information")
            .about("Parse and get original file information from a \".box\" file")
            .alias("info")
            .arg(Arg::new("PATH")
                .help("Specify the the target encrypted \".box\" file")
                .required(true)
                .action(ArgAction::Set)
            )
            .arg(Arg::new("SHOW_UNKNOWN")
                .short('u')
                .long("unknown")
                .help("Show the unknown metadata")
                .action(ArgAction::SetTrue)
            )
        )
        /* PROFILE SUBCOMMAND */
        .subcommand(Command::new("profile")
            .about("Control custom profiles")
            /* CREATE PROFILE SUBCOMMAND */
            .subcommand(Command::new("new")
                .about("Create a new profile")
                .alias("create")
                .arg(Arg::new("NAME")
                    .help("A unique name for the profile")
                    .required(true)
                )
                .arg(Arg::new("PASSWORD")
                    .short('p')
                    .long("password")
                    .help("Specify the password used for authentication")
                    .action(ArgAction::Set)
                )
            )
            /* DELETE PROFILE SUBCOMMAND */
            .subcommand(Command::new("delete")
                .about("Delete a specified profile")
                .alias("remove")
                .arg(Arg::new("NAME")
                    .help("Name of the profile to delete")
                    .required(true)
                )
                .arg(Arg::new("PASSWORD")
                    .short('p')
                    .long("password")
                    .help("Specify the password used for authentication")
                    .action(ArgAction::Set)
                )
            )
            /* SELECT PROFILE SUBCOMMAND */
            .subcommand(Command::new("set")
                .about("Select a profile to use")
                .alias("select")
                .arg(Arg::new("NAME")
                    .help("Name of the profile to switch to")
                    .required(true)
                )
                .arg(Arg::new("PASSWORD")
                    .short('p')
                    .long("password")
                    .help("Specify the password used for authentication")
                    .action(ArgAction::Set)
                )
            )
            /* GET PROFILE SUBCOMMAND */
            .subcommand(Command::new("get")
                .about("Get current profile's name")
                .alias("current")
            )
            /* LIST PROFILE SUBCOMMAND */
            .subcommand(Command::new("list")
                .about("List all available profiles (names)")
            )
        )
        /* KEY SUBCOMMAND */
        .subcommand(Command::new("key")
            .about("Control profile\'s encryption key")
            /* GENERATE KEY SUBCOMMAND */
            .subcommand(Command::new("new")
                .about("Generate a new encryption key for the current profile")
                .alias("generate")
                .arg(Arg::new("PASSWORD")
                    .short('p')
                    .long("password")
                    .help("Specify the password used for authentication")
                    .action(ArgAction::Set)
                )
            )
            /* GET KEY SUBCOMMAND */
            .subcommand(Command::new("get")
                .about("Get current profile\'s encryption key")
                .arg(Arg::new("PASSWORD")
                    .short('p')
                    .long("password")
                    .help("Specify the password used for authentication")
                    .action(ArgAction::Set)
                )
                .arg(Arg::new("AS_BYTE_ARRAY")
                    .help("Output key as an array of bytes")
                    .short('b')
                    .long("byte-array")
                    .action(ArgAction::SetTrue)
                )
            )
            /* SET KEY SUBCOMMAND */
            .subcommand(Command::new("set")
                .about("Set a new key for the current profile")
                .arg(Arg::new("KEY")
                    .help("A 32-byte encryption key represented by hex values (e.g.: DA495EFCF25904AC2FF438BE380FF660E150E65B03AC543398C43AD4FC617962)")
                    .required(true)
                )
                .arg(Arg::new("PASSWORD")
                    .short('p')
                    .long("password")
                    .help("Specify the password used for authentication")
                    .action(ArgAction::Set)
                )
            )
        )
}