git.delta.rocks / unique-network / refs/commits / c849007a9d05

difftreelog

Use env var as node name

Daniel Shiposha2022-03-23parent: #c8aac15.patch.diff
in: master

2 files changed

modifiednode/cli/src/cli.rsdiffbeforeafterboth
before · node/cli/src/cli.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use crate::chain_spec;18use std::path::PathBuf;19use clap::Parser;2021/// Sub-commands supported by the collator.22#[derive(Debug, Parser)]23pub enum Subcommand {24	/// Export the genesis state of the parachain.25	#[clap(name = "export-genesis-state")]26	ExportGenesisState(ExportGenesisStateCommand),2728	/// Export the genesis wasm of the parachain.29	#[clap(name = "export-genesis-wasm")]30	ExportGenesisWasm(ExportGenesisWasmCommand),3132	/// Build a chain specification.33	BuildSpec(sc_cli::BuildSpecCmd),3435	/// Validate blocks.36	CheckBlock(sc_cli::CheckBlockCmd),3738	/// Export blocks.39	ExportBlocks(sc_cli::ExportBlocksCmd),4041	/// Export the state of a given block into a chain spec.42	ExportState(sc_cli::ExportStateCmd),4344	/// Import blocks.45	ImportBlocks(sc_cli::ImportBlocksCmd),4647	/// Remove the whole chain.48	PurgeChain(cumulus_client_cli::PurgeChainCmd),4950	/// Revert the chain to a previous state.51	Revert(sc_cli::RevertCmd),5253	/// The custom benchmark subcommmand benchmarking runtime pallets.54	#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]55	Benchmark(frame_benchmarking_cli::BenchmarkCmd),56}5758/// Command for exporting the genesis state of the parachain59#[derive(Debug, Parser)]60pub struct ExportGenesisStateCommand {61	/// Output file name or stdout if unspecified.62	#[clap(parse(from_os_str))]63	pub output: Option<PathBuf>,6465	/// Id of the parachain this state is for.66	///67	/// Default: 10068	#[clap(long, conflicts_with = "chain")]69	pub parachain_id: Option<u32>,7071	/// Write output in binary. Default is to write in hex.72	#[clap(short, long)]73	pub raw: bool,7475	/// The name of the chain for that the genesis state should be exported.76	#[clap(long, conflicts_with = "parachain-id")]77	pub chain: Option<String>,78}7980/// Command for exporting the genesis wasm file.81#[derive(Debug, Parser)]82pub struct ExportGenesisWasmCommand {83	/// Output file name or stdout if unspecified.84	#[clap(parse(from_os_str))]85	pub output: Option<PathBuf>,8687	/// Write output in binary. Default is to write in hex.88	#[clap(short, long)]89	pub raw: bool,9091	/// The name of the chain for that the genesis wasm file should be exported.92	#[clap(long)]93	pub chain: Option<String>,94}9596#[derive(Debug, Parser)]97#[clap(args_conflicts_with_subcommands = true, subcommand_negates_reqs = true)]98pub struct Cli {99	#[structopt(subcommand)]100	pub subcommand: Option<Subcommand>,101102	#[structopt(flatten)]103	pub run: cumulus_client_cli::RunCmd,104105	/// Relaychain arguments106	#[structopt(raw = true)]107	pub relaychain_args: Vec<String>,108}109110#[derive(Debug)]111pub struct RelayChainCli {112	/// The actual relay chain cli object.113	pub base: polkadot_cli::RunCmd,114115	/// Optional chain id that should be passed to the relay chain.116	pub chain_id: Option<String>,117118	/// The base path that should be used by the relay chain.119	pub base_path: Option<PathBuf>,120}121122impl RelayChainCli {123	/// Parse the relay chain CLI parameters using the para chain `Configuration`.124	pub fn new<'a>(125		para_config: &sc_service::Configuration,126		relay_chain_args: impl Iterator<Item = &'a String>,127	) -> Self {128		let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);129		let chain_id = extension.map(|e| e.relay_chain.clone());130		let base_path = para_config131			.base_path132			.as_ref()133			.map(|x| x.path().join("polkadot"));134		Self {135			base_path,136			chain_id,137			base: polkadot_cli::RunCmd::parse_from(relay_chain_args),138		}139	}140}
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- 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 {