feat: v0.2.1, add version
This commit is contained in:
15
src/cmd_version.rs
Normal file
15
src/cmd_version.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use clap::Args;
|
||||
use rust_util::XResult;
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
pub struct CmdVersion {}
|
||||
|
||||
pub fn version(_cmd_version: CmdVersion) -> XResult<()> {
|
||||
println!(
|
||||
"{} - {}\n{}\n",
|
||||
env!("CARGO_PKG_NAME"),
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
env!("CARGO_PKG_DESCRIPTION")
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use rust_util::XResult;
|
||||
use crate::cmd_decrypt::CmdDecrypt;
|
||||
use crate::cmd_encrypt::CmdEncrypt;
|
||||
use crate::cmd_info::CmdInfo;
|
||||
use crate::cmd_version::CmdVersion;
|
||||
|
||||
mod util;
|
||||
mod util_ecdh;
|
||||
@@ -18,6 +19,7 @@ mod crypto_rsa;
|
||||
mod wrap_key;
|
||||
mod file;
|
||||
mod card;
|
||||
mod cmd_version;
|
||||
mod cmd_info;
|
||||
mod cmd_decrypt;
|
||||
mod cmd_encrypt;
|
||||
@@ -41,6 +43,9 @@ enum Commands {
|
||||
/// Show file info
|
||||
#[command(arg_required_else_help = true, short_flag = 'I')]
|
||||
Info(CmdInfo),
|
||||
/// Show version
|
||||
#[command(short_flag = 'v')]
|
||||
Version(CmdVersion),
|
||||
}
|
||||
|
||||
fn main() -> XResult<()> {
|
||||
@@ -49,5 +54,6 @@ fn main() -> XResult<()> {
|
||||
Commands::Encrypt(cmd_encrypt) => cmd_encrypt::encrypt(cmd_encrypt),
|
||||
Commands::Decrypt(cmd_decrypt) => cmd_decrypt::decrypt(cmd_decrypt),
|
||||
Commands::Info(cmd_info) => cmd_info::info(cmd_info),
|
||||
Commands::Version(cmd_version) => cmd_version::version(cmd_version),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user