actr_cli/commands/
version.rs1use crate::core::{Command, CommandContext, CommandResult, ComponentType};
4use anyhow::Result;
5use async_trait::async_trait;
6use clap::Args;
7
8#[derive(Args, Debug)]
9#[command(
10 about = "Print version, git hash, and build date",
11 long_about = "Print the actr CLI version, git commit hash, and build date."
12)]
13pub struct VersionCommand {
14 #[arg(long)]
16 pub json: bool,
17}
18
19#[async_trait]
20impl Command for VersionCommand {
21 async fn execute(&self, _ctx: &CommandContext) -> Result<CommandResult> {
22 let version = env!("CARGO_PKG_VERSION");
23 let hash = env!("ACTR_GIT_HASH");
24 let date = env!("ACTR_GIT_DATE");
25 if self.json {
26 println!(
27 "{}",
28 serde_json::json!({
29 "version": version,
30 "git_hash": hash,
31 "git_date": date,
32 })
33 );
34 } else {
35 println!("actr {} ({} {})", version, hash, date);
36 }
37 Ok(CommandResult::Success(String::new()))
38 }
39
40 fn required_components(&self) -> Vec<ComponentType> {
41 vec![]
42 }
43
44 fn name(&self) -> &str {
45 "version"
46 }
47
48 fn description(&self) -> &str {
49 "Print version, git hash, and build date"
50 }
51}