--- a/node/cli/src/cli.rs +++ b/node/cli/src/cli.rs @@ -15,9 +15,11 @@ // along with Unique Network. If not, see . use crate::chain_spec; -use std::path::PathBuf; +use std::{path::PathBuf, env}; use clap::Parser; +const NODE_NAME_ENV: &str = "UNIQUE_NODE_NAME"; + /// Sub-commands supported by the collator. #[derive(Debug, Parser)] pub enum Subcommand { @@ -107,6 +109,24 @@ pub relaychain_args: Vec, } +impl Cli { + pub fn node_name() -> String { + match env::var(NODE_NAME_ENV).ok() { + Some(name) => name, + None => { + if cfg!(feature = "unique-runtime") { + "Unique" + } else if cfg!(feature = "quartz-runtime") { + "Quartz" + } else { + "Opal" + } + } + .into(), + } + } +} + #[derive(Debug)] pub struct RelayChainCli { /// The actual relay chain cli object. --- a/node/cli/src/command.rs +++ b/node/cli/src/command.rs @@ -99,7 +99,7 @@ impl SubstrateCli for Cli { // TODO use args fn impl_name() -> String { - "Unique Node".into() + format!("{} Node", Self::node_name()) } fn impl_version() -> String { @@ -108,10 +108,11 @@ // TODO use args fn description() -> String { format!( - "Unique Node\n\nThe command-line arguments provided first will be \ + "{} Node\n\nThe command-line arguments provided first will be \ passed to the parachain node, while the arguments provided after -- will be passed \ to the relaychain node.\n\n\ {} [parachain-args] -- [relaychain-args]", + Self::node_name(), Self::executable_name() ) } @@ -150,7 +151,7 @@ impl SubstrateCli for RelayChainCli { // TODO use args fn impl_name() -> String { - "Unique Node".into() + format!("{} Node", Cli::node_name()) } fn impl_version() -> String { @@ -158,11 +159,13 @@ } // TODO use args fn description() -> String { - "Unique Node\n\nThe command-line arguments provided first will be \ - passed to the parachain node, while the arguments provided after -- will be passed \ - to the relaychain node.\n\n\ - parachain-collator [parachain-args] -- [relaychain-args]" - .into() + format!( + "{} Node\n\nThe command-line arguments provided first will be \ + passed to the parachain node, while the arguments provided after -- will be passed \ + to the relaychain node.\n\n\ + parachain-collator [parachain-args] -- [relaychain-args]", + Cli::node_name() + ) } fn author() -> String {