feat: PGP decrypt works

This commit is contained in:
2023-09-07 01:08:12 +08:00
parent 34fd7d0e47
commit 8939237d99
5 changed files with 176 additions and 17 deletions

View File

@@ -3,7 +3,7 @@ extern crate core;
use std::path::PathBuf;
use clap::{Parser, Subcommand};
use rust_util::{information, XResult};
use rust_util::{failure, information, success, XResult};
mod util;
mod config;
@@ -35,6 +35,8 @@ enum Commands {
Decrypt {
/// Files need to be decrypted
paths: Vec<PathBuf>,
#[arg(long)]
pin: Option<String>,
},
/// Show file info
#[command(arg_required_else_help = true, short_flag = 'I')]
@@ -54,9 +56,12 @@ fn main() -> XResult<()> {
paths.iter().for_each(|f| information!("{:?}", f));
Ok(())
}
Commands::Decrypt { mut paths } => {
for path in paths {
cmd_decrypt::decrypt(path, &Some("123456".to_string())).unwrap();
Commands::Decrypt { mut paths, pin } => {
for path in &paths {
match cmd_decrypt::decrypt(path, &pin) {
Ok(_) => success!("Decrypt {} succeed", path.to_str().unwrap_or("N/A")),
Err(e) => failure!("Decrypt {} failed: {}", path.to_str().unwrap_or("N/A"), e),
}
}
Ok(())
}