feat: claps
This commit is contained in:
46
src/main.rs
Normal file
46
src/main.rs
Normal 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!()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user