diff --git a/substrate/cli/src/lib.rs b/substrate/cli/src/lib.rs index ab31b6312dd89..462eb0605f5f6 100644 --- a/substrate/cli/src/lib.rs +++ b/substrate/cli/src/lib.rs @@ -45,7 +45,6 @@ extern crate exit_future; #[macro_use] extern crate lazy_static; -#[macro_use] extern crate clap; #[macro_use] extern crate error_chain; @@ -168,6 +167,10 @@ where { panic_hook::set(); + let full_version = service::config::full_version_from_strs( + version.version, + version.commit + ); let yaml = format!(include_str!("./cli.yml"), name = version.executable_name, description = version.description, @@ -175,7 +178,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(), diff --git a/substrate/service/src/config.rs b/substrate/service/src/config.rs index b3e42c9b6c0f5..5eda5fe1000d7 100644 --- a/substrate/service/src/config.rs +++ b/substrate/service/src/config.rs @@ -101,17 +101,9 @@ impl Configuration String { - let env = Target::env(); - let env_dash = if env.is_empty() { "" } else { "-" }; - format!("{}-{}{}{}", Target::arch(), Target::os(), env_dash, env) - } - - /// Returns full version string. + /// Returns full version string of this configuration. pub fn full_version(&self) -> String { - let commit_dash = if self.impl_commit.is_empty() { "" } else { "-" }; - format!("{}{}{}-{}", self.impl_version, commit_dash, self.impl_commit, Self::platform()) + full_version_from_strs(self.impl_version, self.impl_commit) } /// Implementation id and version. @@ -119,3 +111,17 @@ impl Configuration String { + let env = Target::env(); + let env_dash = if env.is_empty() { "" } else { "-" }; + format!("{}-{}{}{}", Target::arch(), Target::os(), env_dash, env) +} + +/// 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, platform()) +} + diff --git a/substrate/service/src/lib.rs b/substrate/service/src/lib.rs index 1c7a85a285372..2bc0e272e4951 100644 --- a/substrate/service/src/lib.rs +++ b/substrate/service/src/lib.rs @@ -50,8 +50,8 @@ extern crate serde_derive; mod components; mod error; -mod config; mod chain_spec; +pub mod config; pub mod chain_ops; use std::io;