diff --git a/src/cmd/version.rs b/src/cmd/version.rs index 3dc6522..9fcf69c 100644 --- a/src/cmd/version.rs +++ b/src/cmd/version.rs @@ -1,14 +1,23 @@ use anyhow::Result; use clap::Parser; -use crate::BUILD_INFO; +use crate::{BUILD_INFO, VERSION}; #[derive(Debug, Parser)] -pub struct Cmd {} +pub struct Cmd { + #[clap(short, long)] + short: bool, +} impl Cmd { pub fn run(self) -> Result<()> { - println!("{}", BUILD_INFO); + println!( + "{}", + match self.short { + true => VERSION, + _ => BUILD_INFO, + }, + ); Ok(()) } diff --git a/src/main.rs b/src/main.rs index 21a714b..b5c0ff4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,8 @@ const BUILD_INFO: &str = build_info::format!( $.timestamp, ); +const VERSION: &str = build_info::format!("{}", $.crate_info.version); + #[tokio::main] async fn main() { if let Err(e) = Cli::parse().run().await {