Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions substrate/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -164,14 +163,17 @@ where
{
panic_hook::set();

let full_version = service::Configuration::<<F>::Configuration, <F>::Genesis>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this type would not be necessary to specify if this were a free function. i.e. it would just be
let full_version = service::full_version_from_strs(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed up in #496

::full_version_from_strs(version.version, version.commit);

let yaml = format!(include_str!("./cli.yml"),
name = version.executable_name,
description = version.description,
author = version.author,
);
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(),
Expand Down
11 changes: 8 additions & 3 deletions substrate/service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,15 @@ impl<C: Default, G: Serialize + DeserializeOwned + BuildStorage> Configuration<C
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())
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: bad style to have a function without self parameter inside an impl block. Could you move this to a free function in the module?

let commit_dash = if impl_commit.is_empty() { "" } else { "-" };
format!("{}{}{}-{}", impl_version, commit_dash, impl_commit, Self::platform())
}

/// Implementation id and version.
Expand Down