diff --git a/apps/fieldcraft-cli/src/main.rs b/apps/fieldcraft-cli/src/main.rs index 5c7c228..6ce2ff7 100644 --- a/apps/fieldcraft-cli/src/main.rs +++ b/apps/fieldcraft-cli/src/main.rs @@ -2,6 +2,7 @@ //! fieldcraft-cli run //! fieldcraft-cli features //! fieldcraft-cli mcp [--connect ADDR | --headless] [--automation-read-root DIR] [--automation-write-root DIR] +//! fieldcraft-cli --version #![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] #![forbid(unsafe_code)] @@ -26,6 +27,7 @@ usage: --automation-read-root DIR files may be read only inside DIR --automation-write-root DIR files may be written only inside DIR (with either root, the access a root left out is not granted) + fieldcraft-cli --version print the version "; /// Largest script accepted (bytes). @@ -46,6 +48,10 @@ fn main() -> ExitCode { } Some("mcp") => mcp(args.get(1..).unwrap_or(&[])), Some("run") => args.get(1).ok_or_else(|| format!("run needs a script\n\n{USAGE}")).and_then(|p| run(p)), + Some("-V" | "--version") => { + println!("fieldcraft-cli {}", env!("CARGO_PKG_VERSION")); + Ok(()) + } Some("-h" | "--help" | "help") | None => { print!("{USAGE}"); Ok(()) diff --git a/apps/fieldcraft-cli/tests/version.rs b/apps/fieldcraft-cli/tests/version.rs new file mode 100644 index 0000000..9658ec8 --- /dev/null +++ b/apps/fieldcraft-cli/tests/version.rs @@ -0,0 +1,12 @@ +//! `fieldcraft-cli --version`, which the release packaging runs to check each build. + +use std::process::Command; + +#[test] +fn version_prints_the_workspace_version() { + for flag in ["--version", "-V"] { + let out = Command::new(env!("CARGO_BIN_EXE_fieldcraft-cli")).arg(flag).output().unwrap(); + assert!(out.status.success(), "{flag}: {out:?}"); + assert_eq!(String::from_utf8_lossy(&out.stdout).trim(), format!("fieldcraft-cli {}", env!("CARGO_PKG_VERSION"))); + } +}