allow BARK_PKG_VERSION to override CARGO_PKG_VERSION at compile time

This commit is contained in:
Hailey Somerville 2023-12-29 23:23:28 +11:00
parent 0a555d4883
commit 8ee86b901a

View file

@ -14,6 +14,7 @@ use structopt::StructOpt;
use thiserror::Error;
#[derive(StructOpt)]
#[structopt(version = version())]
enum Opt {
Stream(stream::StreamOpt),
Receive(receive::ReceiveOpt),
@ -68,3 +69,10 @@ fn default_log_level() -> LevelFilter {
LevelFilter::Info
}
}
const fn version() -> &'static str {
match option_env!("BARK_PKG_VERSION") {
Some(ver) => ver,
None => env!("CARGO_PKG_VERSION"),
}
}