diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index ecbdd18958..47fa5f3ae7 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -1712,7 +1712,6 @@ dependencies = [ name = "node-cli" version = "0.1.0" dependencies = [ - "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/substrate/core/cli/src/lib.rs b/substrate/core/cli/src/lib.rs index 6dc1549a2c..29d3d45932 100644 --- a/substrate/core/cli/src/lib.rs +++ b/substrate/core/cli/src/lib.rs @@ -85,6 +85,8 @@ use futures::Future; /// Executable version. Used to pass version information from the root crate. pub struct VersionInfo { + /// Implemtation name. + pub name: &'static str, /// Implementation version. pub version: &'static str, /// SCM Commit hash. @@ -130,13 +132,16 @@ fn load_spec(matches: &clap::ArgMatches, factory: F) -> Result PathBuf { +fn base_path(matches: &clap::ArgMatches, version: &VersionInfo) -> PathBuf { matches.value_of("base_path") .map(|x| Path::new(x).to_owned()) .unwrap_or_else(|| app_dirs::get_app_root( AppDataType::UserData, - app_info, + &AppInfo { + name: version.executable_name, + author: version.author + } ).expect("app directories exist on all supported platforms; qed") ) } @@ -193,10 +198,9 @@ where /// Parse clap::Matches into config and chain specification pub fn parse_matches<'a, F, S>( spec_factory: S, - version: VersionInfo, + version: &VersionInfo, impl_name: &'static str, matches: &clap::ArgMatches<'a>, - app_info: &AppInfo, ) -> error::Result<(ChainSpec<::Genesis>, FactoryFullConfiguration)> where F: ServiceFactory, @@ -226,7 +230,7 @@ where ) } - let base_path = base_path(&matches, &app_info); + let base_path = base_path(&matches, version); config.keystore_path = matches.value_of("keystore") .map(|x| Path::new(x).to_owned()) @@ -344,7 +348,7 @@ where fn get_db_path_for_subcommand( main_cmd: &clap::ArgMatches, sub_cmd: &clap::ArgMatches, - app_info: &AppInfo, + version: &VersionInfo, ) -> error::Result { if main_cmd.is_present("chain") && sub_cmd.is_present("chain") { bail!(create_input_err("`--chain` option is present two times")); @@ -375,9 +379,9 @@ fn get_db_path_for_subcommand( } let base_path = if sub_cmd.is_present("base_path") { - base_path(sub_cmd, app_info) + base_path(sub_cmd, version) } else { - base_path(main_cmd, app_info) + base_path(main_cmd, version) }; Ok(db_path(&base_path, &spec_id)) @@ -397,7 +401,7 @@ pub fn execute_default<'a, F, E>( exit: E, matches: &clap::ArgMatches<'a>, config: &FactoryFullConfiguration, - app_info: &AppInfo, + app_info: &VersionInfo, ) -> error::Result> where E: IntoExit, diff --git a/substrate/node/cli/Cargo.toml b/substrate/node/cli/Cargo.toml index 80828216f0..f0d570a8d2 100644 --- a/substrate/node/cli/Cargo.toml +++ b/substrate/node/cli/Cargo.toml @@ -13,7 +13,6 @@ exit-future = "0.1" substrate-cli = { path = "../../core/cli" } parity-codec = { version = "2.2" } slog = "^2" -app_dirs = "1.2" sr-io = { path = "../../core/sr-io" } substrate-client = { path = "../../core/client" } substrate-primitives = { path = "../../core/primitives" } diff --git a/substrate/node/cli/src/lib.rs b/substrate/node/cli/src/lib.rs index 4eb9a7f243..8581e94780 100644 --- a/substrate/node/cli/src/lib.rs +++ b/substrate/node/cli/src/lib.rs @@ -20,7 +20,6 @@ #![warn(unused_extern_crates)] extern crate tokio; -extern crate app_dirs; extern crate substrate_cli as cli; extern crate substrate_primitives as primitives; @@ -58,13 +57,6 @@ use substrate_service::{ServiceFactory, Roles as ServiceRoles}; use params::{Params as NodeParams}; use structopt::StructOpt; use std::ops::Deref; -use app_dirs::AppInfo; - - -const APP_INFO: AppInfo = AppInfo { - name: "Substrate Node", - author: "Parity Technologies" -}; /// The chain specification option. #[derive(Clone, Debug)] @@ -130,15 +122,15 @@ pub fn run(args: I, exit: E, version: cli::VersionInfo) -> error::Resul }; let (spec, config) = cli::parse_matches::( - load_spec, version, "substrate-node", &matches, &APP_INFO + load_spec, &version, "substrate-node", &matches )?; - match cli::execute_default::(spec, exit, &matches, &config, &APP_INFO)? { + match cli::execute_default::(spec, exit, &matches, &config, &version)? { cli::Action::ExecutedInternally => (), cli::Action::RunService(exit) => { - info!("{}", APP_INFO.name); + info!("{}", version.name); info!(" version {}", config.full_version()); - info!(" by {}, 2017, 2018", APP_INFO.author); + info!(" by {}, 2017, 2018", version.author); info!("Chain specification: {}", config.chain_spec.name()); info!("Node name: {}", config.name); info!("Roles: {:?}", config.roles); diff --git a/substrate/node/src/main.rs b/substrate/node/src/main.rs index 1f55cd7aab..fdc51cdc1e 100644 --- a/substrate/node/src/main.rs +++ b/substrate/node/src/main.rs @@ -54,10 +54,11 @@ quick_main!(run); fn run() -> cli::error::Result<()> { let version = VersionInfo { + name: "Substrate Node", commit: env!("VERGEN_SHA_SHORT"), version: env!("CARGO_PKG_VERSION"), executable_name: "substrate", - author: "Parity Team ", + author: "Parity Technologies ", description: "Generic substrate node", }; cli::run(::std::env::args(), Exit, version)