feat: claps

This commit is contained in:
2023-02-09 22:34:50 +08:00
parent 1773a3036c
commit 4baf429574
4 changed files with 87 additions and 2 deletions

46
src/main.rs Normal file
View File

@@ -0,0 +1,46 @@
use std::path::PathBuf;
use clap::{Parser, Subcommand};
use rust_util::information;
mod spec;
#[derive(Debug, Parser)]
#[command(name = "tiny-encrypt-rs")]
#[command(about = "A tiny encrypt client in Rust", long_about = None)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Debug, Subcommand)]
enum Commands {
/// Encrypt file(s)
#[command(arg_required_else_help = true, short_flag = 'e')]
Encrypt {
/// Files need to be encrypted
files: Vec<PathBuf>,
},
/// Decrypt file(s)
#[command(arg_required_else_help = true, short_flag = 'd')]
Decrypt {
/// Files need to be decrypted
files: Vec<PathBuf>,
},
/// Show file info
#[command(arg_required_else_help = true, short_flag = 'i')]
Info {
file: PathBuf,
},
}
fn main() {
let args = Cli::parse();
match args.command {
Commands::Encrypt { files } => {
files.iter().for_each(|f| information!("{:?}", f));
}
Commands::Decrypt { .. } => todo!(),
Commands::Info { .. } => todo!()
}
}