feat: cmd info works
This commit is contained in:
25
src/main.rs
25
src/main.rs
@@ -1,13 +1,15 @@
|
||||
extern crate core;
|
||||
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use rust_util::information;
|
||||
use rust_util::{information, XResult};
|
||||
|
||||
mod spec;
|
||||
mod crypto;
|
||||
mod file;
|
||||
mod cmd_info;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(name = "tiny-encrypt-rs")]
|
||||
@@ -23,28 +25,33 @@ enum Commands {
|
||||
#[command(arg_required_else_help = true, short_flag = 'e')]
|
||||
Encrypt {
|
||||
/// Files need to be encrypted
|
||||
files: Vec<PathBuf>,
|
||||
paths: Vec<PathBuf>,
|
||||
},
|
||||
/// Decrypt file(s)
|
||||
#[command(arg_required_else_help = true, short_flag = 'd')]
|
||||
Decrypt {
|
||||
/// Files need to be decrypted
|
||||
files: Vec<PathBuf>,
|
||||
paths: Vec<PathBuf>,
|
||||
},
|
||||
/// Show file info
|
||||
#[command(arg_required_else_help = true, short_flag = 'I')]
|
||||
Info {
|
||||
file: PathBuf,
|
||||
path: PathBuf,
|
||||
},
|
||||
}
|
||||
|
||||
fn main() {
|
||||
fn main() -> XResult<()> {
|
||||
let args = Cli::parse();
|
||||
match args.command {
|
||||
Commands::Encrypt { files } => {
|
||||
files.iter().for_each(|f| information!("{:?}", f));
|
||||
Commands::Encrypt { paths } => {
|
||||
paths.iter().for_each(|f| information!("{:?}", f));
|
||||
Ok(())
|
||||
}
|
||||
Commands::Decrypt { .. } => {
|
||||
Ok(())
|
||||
}
|
||||
Commands::Info { path } => {
|
||||
cmd_info::info(path)
|
||||
}
|
||||
Commands::Decrypt { .. } => todo!(),
|
||||
Commands::Info { .. } => todo!()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user