mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
use the version function for s2s API too
This way the extra version information can appear there as well. Mainly useful for showing off :P
This commit is contained in:
parent
a25f2ec950
commit
509b70bd82
3 changed files with 16 additions and 16 deletions
|
|
@ -515,7 +515,7 @@ pub(crate) async fn get_server_version_route(
|
|||
Ok(get_server_version::v1::Response {
|
||||
server: Some(get_server_version::v1::Server {
|
||||
name: Some(env!("CARGO_PKG_NAME").to_owned()),
|
||||
version: Some(env!("CARGO_PKG_VERSION").to_owned()),
|
||||
version: Some(crate::version()),
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
16
src/clap.rs
16
src/clap.rs
|
|
@ -2,23 +2,9 @@
|
|||
|
||||
use clap::Parser;
|
||||
|
||||
/// Returns the current version of the crate with extra info if supplied
|
||||
///
|
||||
/// Set the environment variable `GRAPEVINE_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!("GRAPEVINE_VERSION_EXTRA") {
|
||||
Some(x) => format!("{cargo_pkg_version} ({x})"),
|
||||
None => cargo_pkg_version.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Command line arguments
|
||||
#[derive(Parser)]
|
||||
#[clap(about, version = version())]
|
||||
#[clap(about, version = crate::version())]
|
||||
pub(crate) struct Args;
|
||||
|
||||
/// Parse command line arguments into structured data
|
||||
|
|
|
|||
14
src/main.rs
14
src/main.rs
|
|
@ -71,6 +71,20 @@ pub(crate) fn services() -> &'static Services {
|
|||
.expect("SERVICES should be initialized when this is called")
|
||||
}
|
||||
|
||||
/// Returns the current version of the crate with extra info if supplied
|
||||
///
|
||||
/// Set the environment variable `GRAPEVINE_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!("GRAPEVINE_VERSION_EXTRA") {
|
||||
Some(x) => format!("{cargo_pkg_version} ({x})"),
|
||||
None => cargo_pkg_version.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
clap::parse();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue