Skip to content

Commit

Permalink
feat: Add rudimentary version flag
Browse files Browse the repository at this point in the history
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
  • Loading branch information
joonas committed Sep 23, 2024
1 parent 0aaa277 commit 813bf19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasmcloud-operator"
version = "0.4.1"
version = "0.4.2"
edition = "2021"

[[bin]]
Expand Down
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ use wasmcloud_operator_types::v1alpha1::WasmCloudHostConfig;

#[tokio::main]
async fn main() -> Result<()> {
let args = std::env::args().collect::<Vec<_>>();
if args.iter().any(|arg| arg == "-V" || arg == "--version") {
let version = version();
println!("{} {version}", env!("CARGO_BIN_NAME"));
std::process::exit(0);
}

let tracing_enabled = std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT").is_ok();
configure_tracing(tracing_enabled).map_err(|e| {
error!("Failed to configure tracing: {}", e);
Expand Down Expand Up @@ -192,3 +199,7 @@ async fn install_crd(client: &Client) -> anyhow::Result<()> {

Ok(())
}

fn version() -> &'static str {
option_env!("CARGO_VERSION_INFO").unwrap_or(env!("CARGO_PKG_VERSION"))
}

0 comments on commit 813bf19

Please sign in to comment.