From e809af5a2c8f10c77d2e17a654557e0ae9b11b76 Mon Sep 17 00:00:00 2001 From: Simon Littlejohns <39836665+simonljs@users.noreply.github.com> Date: Fri, 3 Aug 2018 10:02:22 +0100 Subject: [PATCH 1/2] Update config.rs --- substrate/service/src/config.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/substrate/service/src/config.rs b/substrate/service/src/config.rs index 83f3887c5b50b..7a5696bc261e4 100644 --- a/substrate/service/src/config.rs +++ b/substrate/service/src/config.rs @@ -105,10 +105,15 @@ impl Configuration String { - let commit_dash = if self.impl_commit.is_empty() { "" } else { "-" }; - format!("{}{}{}-{}", self.impl_version, commit_dash, self.impl_commit, Self::platform()) + Self::full_version_from_strs(self.impl_version, self.impl_commit) + } + + /// Returns full version string, using supplied version and commit. + pub fn full_version_from_strs(impl_version: &str, impl_commit: &str) -> String { + let commit_dash = if impl_commit.is_empty() { "" } else { "-" }; + format!("{}{}{}-{}", impl_version, commit_dash, impl_commit, Self::platform()) } /// Implementation id and version. From 5c019974f20676b431e73ae3d29a4722d76233c4 Mon Sep 17 00:00:00 2001 From: Simon Littlejohns <39836665+simonljs@users.noreply.github.com> Date: Fri, 3 Aug 2018 10:04:18 +0100 Subject: [PATCH 2/2] Update lib.rs --- substrate/cli/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/substrate/cli/src/lib.rs b/substrate/cli/src/lib.rs index 9b3c1ca44d307..d3512a415f1e9 100644 --- a/substrate/cli/src/lib.rs +++ b/substrate/cli/src/lib.rs @@ -44,7 +44,6 @@ extern crate exit_future; #[macro_use] extern crate lazy_static; -#[macro_use] extern crate clap; #[macro_use] extern crate error_chain; @@ -164,6 +163,9 @@ where { panic_hook::set(); + let full_version = service::Configuration::<::Configuration, ::Genesis> + ::full_version_from_strs(version.version, version.commit); + let yaml = format!(include_str!("./cli.yml"), name = version.executable_name, description = version.description, @@ -171,7 +173,7 @@ where ); let yaml = &clap::YamlLoader::load_from_str(&yaml).expect("Invalid yml file")[0]; let matches = match clap::App::from_yaml(yaml) - .version(&(crate_version!().to_owned() + "\n")[..]) + .version(&(full_version + "\n")[..]) .get_matches_from_safe(args) { Ok(m) => m, Err(e) => e.exit(),