1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-11-16 14:00:51 +01:00

Merge branch 'version-extra' into 'next'

allow including extra info in `--version` output

See merge request famedly/conduit!601
This commit is contained in:
Charles Hall 2024-04-11 14:37:37 +00:00
commit 7f63948db9
3 changed files with 17 additions and 2 deletions

View file

@ -102,7 +102,7 @@ thread_local = "1.1.7"
hmac = "0.12.1" hmac = "0.12.1"
sha-1 = "0.10.1" sha-1 = "0.10.1"
# used for conduit's CLI and admin room command parsing # used for conduit's CLI and admin room command parsing
clap = { version = "4.3.0", default-features = false, features = ["std", "derive", "help", "usage", "error-context"] } clap = { version = "4.3.0", default-features = false, features = ["std", "derive", "help", "usage", "error-context", "string"] }
futures-util = { version = "0.3.28", default-features = false } futures-util = { version = "0.3.28", default-features = false }
# Used for reading the configuration from conduit.toml & environment variables # Used for reading the configuration from conduit.toml & environment variables
figment = { version = "0.10.8", features = ["env", "toml"] } figment = { version = "0.10.8", features = ["env", "toml"] }

View file

@ -73,6 +73,7 @@
}); });
env = pkgs: { env = pkgs: {
CONDUIT_VERSION_EXTRA = self.shortRev or self.dirtyShortRev;
ROCKSDB_INCLUDE_DIR = "${rocksdb' pkgs}/include"; ROCKSDB_INCLUDE_DIR = "${rocksdb' pkgs}/include";
ROCKSDB_LIB_DIR = "${rocksdb' pkgs}/lib"; ROCKSDB_LIB_DIR = "${rocksdb' pkgs}/lib";
} }

View file

@ -2,9 +2,23 @@
use clap::Parser; use clap::Parser;
/// Returns the current version of the crate with extra info if supplied
///
/// Set the environment variable `CONDUIT_VERSION_EXTRA` to any UTF-8 string to
/// include it in parenthesis after the SemVer version. A common value are git
/// commit hashes.
fn version() -> String {
let cargo_pkg_version = env!("CARGO_PKG_VERSION");
match option_env!("CONDUIT_VERSION_EXTRA") {
Some(x) => format!("{} ({})", cargo_pkg_version, x),
None => cargo_pkg_version.to_owned(),
}
}
/// Command line arguments /// Command line arguments
#[derive(Parser)] #[derive(Parser)]
#[clap(about, version)] #[clap(about, version = version())]
pub struct Args {} pub struct Args {}
/// Parse command line arguments into structured data /// Parse command line arguments into structured data