Skip to content

Commit 309b492

Browse files
authored
feat: Add rudimentary version flag (#95)
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
1 parent 0aaa277 commit 309b492

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wasmcloud-operator"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
edition = "2021"
55

66
[[bin]]

src/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ use wasmcloud_operator_types::v1alpha1::WasmCloudHostConfig;
2828

2929
#[tokio::main]
3030
async fn main() -> Result<()> {
31+
let args = std::env::args().collect::<Vec<_>>();
32+
if args.iter().any(|arg| arg == "-V" || arg == "--version") {
33+
let version = version();
34+
println!("{} {version}", env!("CARGO_BIN_NAME"));
35+
std::process::exit(0);
36+
}
37+
3138
let tracing_enabled = std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT").is_ok();
3239
configure_tracing(tracing_enabled).map_err(|e| {
3340
error!("Failed to configure tracing: {}", e);
@@ -192,3 +199,7 @@ async fn install_crd(client: &Client) -> anyhow::Result<()> {
192199

193200
Ok(())
194201
}
202+
203+
fn version() -> &'static str {
204+
option_env!("CARGO_VERSION_INFO").unwrap_or(env!("CARGO_PKG_VERSION"))
205+
}

0 commit comments

Comments
 (0)