Skip to content

Commit cf4eada

Browse files
authored
Introduced 'version' command to all relevant binaries (#969)
* Introduced 'version' command to all relevant binaries * Removed separate 'version' subcommand in favour of clap's 'long_version' field
1 parent f43f07f commit cf4eada

File tree

16 files changed

+304
-20
lines changed

16 files changed

+304
-20
lines changed

Cargo.lock

+79
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/native/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ coconut = ["coconut-interface", "credentials", "gateway-requests/coconut", "gate
5151

5252
[dev-dependencies]
5353
serde_json = "1.0" # for the "textsend" example
54+
55+
[build-dependencies]
56+
vergen = { version = "5", default-features = false, features = ["build", "git", "rustc", "cargo"] }

clients/native/build.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright 2021 - Nym Technologies SA <[email protected]>
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
use vergen::{vergen, Config};
5+
6+
fn main() {
7+
vergen(Config::default()).expect("failed to extract build metadata")
8+
}

clients/native/src/main.rs

+35-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2021 - Nym Technologies SA <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use clap::{App, ArgMatches};
4+
use clap::{crate_version, App, ArgMatches};
55

66
pub mod client;
77
pub mod commands;
@@ -13,7 +13,8 @@ fn main() {
1313
println!("{}", banner());
1414

1515
let arg_matches = App::new("Nym Client")
16-
.version(env!("CARGO_PKG_VERSION"))
16+
.version(crate_version!())
17+
.long_version(&*long_version())
1718
.author("Nymtech")
1819
.about("Implementation of the Nym Client")
1920
.subcommand(commands::init::command_args())
@@ -50,7 +51,38 @@ fn banner() -> String {
5051
(client - version {:})
5152
5253
"#,
53-
env!("CARGO_PKG_VERSION")
54+
crate_version!()
55+
)
56+
}
57+
58+
fn long_version() -> String {
59+
format!(
60+
r#"
61+
{:<20}{}
62+
{:<20}{}
63+
{:<20}{}
64+
{:<20}{}
65+
{:<20}{}
66+
{:<20}{}
67+
{:<20}{}
68+
{:<20}{}
69+
"#,
70+
"Build Timestamp:",
71+
env!("VERGEN_BUILD_TIMESTAMP"),
72+
"Build Version:",
73+
env!("VERGEN_BUILD_SEMVER"),
74+
"Commit SHA:",
75+
env!("VERGEN_GIT_SHA"),
76+
"Commit Date:",
77+
env!("VERGEN_GIT_COMMIT_TIMESTAMP"),
78+
"Commit Branch:",
79+
env!("VERGEN_GIT_BRANCH"),
80+
"rustc Version:",
81+
env!("VERGEN_RUSTC_SEMVER"),
82+
"rustc Channel:",
83+
env!("VERGEN_RUSTC_CHANNEL"),
84+
"cargo Profile:",
85+
env!("VERGEN_CARGO_PROFILE"),
5486
)
5587
}
5688

clients/socks5/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ network-defaults = { path = "../../common/network-defaults" }
4343

4444
[features]
4545
coconut = ["coconut-interface", "credentials", "gateway-requests/coconut", "gateway-client/coconut"]
46+
47+
[build-dependencies]
48+
vergen = { version = "5", default-features = false, features = ["build", "git", "rustc", "cargo"] }

clients/socks5/build.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright 2021 - Nym Technologies SA <[email protected]>
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
use vergen::{vergen, Config};
5+
6+
fn main() {
7+
vergen(Config::default()).expect("failed to extract build metadata")
8+
}

clients/socks5/src/main.rs

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2021 - Nym Technologies SA <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use clap::{App, ArgMatches};
4+
use clap::{crate_version, App, ArgMatches};
55

66
pub mod client;
77
mod commands;
@@ -15,6 +15,7 @@ fn main() {
1515
let arg_matches = App::new("Nym Socks5 Proxy")
1616
.version(env!("CARGO_PKG_VERSION"))
1717
.author("Nymtech")
18+
.long_version(&*long_version())
1819
.about("A Socks5 localhost proxy that converts incoming messages to Sphinx and sends them to a Nym address")
1920
.subcommand(commands::init::command_args())
2021
.subcommand(commands::run::command_args())
@@ -50,7 +51,38 @@ fn banner() -> String {
5051
(socks5 proxy - version {:})
5152
5253
"#,
53-
env!("CARGO_PKG_VERSION")
54+
crate_version!()
55+
)
56+
}
57+
58+
fn long_version() -> String {
59+
format!(
60+
r#"
61+
{:<20}{}
62+
{:<20}{}
63+
{:<20}{}
64+
{:<20}{}
65+
{:<20}{}
66+
{:<20}{}
67+
{:<20}{}
68+
{:<20}{}
69+
"#,
70+
"Build Timestamp:",
71+
env!("VERGEN_BUILD_TIMESTAMP"),
72+
"Build Version:",
73+
env!("VERGEN_BUILD_SEMVER"),
74+
"Commit SHA:",
75+
env!("VERGEN_GIT_SHA"),
76+
"Commit Date:",
77+
env!("VERGEN_GIT_COMMIT_TIMESTAMP"),
78+
"Commit Branch:",
79+
env!("VERGEN_GIT_BRANCH"),
80+
"rustc Version:",
81+
env!("VERGEN_RUSTC_SEMVER"),
82+
"rustc Channel:",
83+
env!("VERGEN_RUSTC_CHANNEL"),
84+
"cargo Profile:",
85+
env!("VERGEN_CARGO_PROFILE"),
5486
)
5587
}
5688

gateway/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ coconut = ["coconut-interface", "gateway-requests/coconut", "gateway-client/coco
5656
[build-dependencies]
5757
tokio = { version = "1.4", features = ["rt-multi-thread", "macros"] }
5858
sqlx = { version = "0.5", features = ["runtime-tokio-rustls", "sqlite", "macros", "migrate"] }
59+
vergen = { version = "5", default-features = false, features = ["build", "git", "rustc", "cargo"] }

gateway/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use sqlx::{Connection, SqliteConnection};
22
use std::env;
3+
use vergen::{vergen, Config};
34

45
#[tokio::main]
56
async fn main() {
@@ -22,4 +23,6 @@ async fn main() {
2223
// for some strange reason we need to add a leading `/` to the windows path even though it's
2324
// not a valid windows path... but hey, it works...
2425
println!("cargo:rustc-env=DATABASE_URL=sqlite:///{}", &database_path);
26+
27+
vergen(Config::default()).expect("failed to extract build metadata")
2528
}

gateway/src/main.rs

+35-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2020 - Nym Technologies SA <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use clap::{App, ArgMatches};
4+
use clap::{crate_version, App, ArgMatches};
55

66
mod commands;
77
mod config;
@@ -14,7 +14,8 @@ async fn main() {
1414
println!("{}", banner());
1515

1616
let arg_matches = App::new("Nym Mixnet Gateway")
17-
.version(env!("CARGO_PKG_VERSION"))
17+
.version(crate_version!())
18+
.long_version(&*long_version())
1819
.author("Nymtech")
1920
.about("Implementation of the Nym Mixnet Gateway")
2021
.subcommand(commands::init::command_args())
@@ -53,7 +54,38 @@ fn banner() -> String {
5354
(gateway - version {:})
5455
5556
"#,
56-
env!("CARGO_PKG_VERSION")
57+
crate_version!()
58+
)
59+
}
60+
61+
fn long_version() -> String {
62+
format!(
63+
r#"
64+
{:<20}{}
65+
{:<20}{}
66+
{:<20}{}
67+
{:<20}{}
68+
{:<20}{}
69+
{:<20}{}
70+
{:<20}{}
71+
{:<20}{}
72+
"#,
73+
"Build Timestamp:",
74+
env!("VERGEN_BUILD_TIMESTAMP"),
75+
"Build Version:",
76+
env!("VERGEN_BUILD_SEMVER"),
77+
"Commit SHA:",
78+
env!("VERGEN_GIT_SHA"),
79+
"Commit Date:",
80+
env!("VERGEN_GIT_COMMIT_TIMESTAMP"),
81+
"Commit Branch:",
82+
env!("VERGEN_GIT_BRANCH"),
83+
"rustc Version:",
84+
env!("VERGEN_RUSTC_SEMVER"),
85+
"rustc Channel:",
86+
env!("VERGEN_RUSTC_CHANNEL"),
87+
"cargo Profile:",
88+
env!("VERGEN_CARGO_PROFILE"),
5789
)
5890
}
5991

mixnode/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ version-checker = { path="../common/version-checker" }
4747

4848
[dev-dependencies]
4949
serial_test = "0.5"
50+
51+
[build-dependencies]
52+
vergen = { version = "5", default-features = false, features = ["build", "git", "rustc", "cargo"] }

mixnode/build.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright 2021 - Nym Technologies SA <[email protected]>
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
use vergen::{vergen, Config};
5+
6+
fn main() {
7+
vergen(Config::default()).expect("failed to extract build metadata")
8+
}

0 commit comments

Comments
 (0)