diff --git a/Cargo.lock b/Cargo.lock index 047728f..7ebdcdb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2063,7 +2063,7 @@ dependencies = [ [[package]] name = "tiny-encrypt" -version = "0.2.0" +version = "0.2.1" dependencies = [ "aes-gcm-stream", "base64", diff --git a/Cargo.toml b/Cargo.toml index 496128f..312c984 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tiny-encrypt" -version = "0.2.0" +version = "0.2.1" edition = "2021" license = "MIT" description = "A simple and tiny file encrypt tool" diff --git a/src/cmd_version.rs b/src/cmd_version.rs new file mode 100644 index 0000000..1d46dd7 --- /dev/null +++ b/src/cmd_version.rs @@ -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(()) +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 2df3bce..1120269 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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), } } \ No newline at end of file