feat: PGP decrypt works
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user