git.delta.rocks / unique-network / refs/commits / 4e90c111d3d7

difftreelog

source

node/cli/src/cli.rs3.5 KiBsourcehistory
1use crate::chain_spec;2use std::path::PathBuf;3use structopt::StructOpt;45/// Sub-commands supported by the collator.6#[derive(Debug, StructOpt)]7pub enum Subcommand {8	/// Export the genesis state of the parachain.9	#[structopt(name = "export-genesis-state")]10	ExportGenesisState(ExportGenesisStateCommand),1112	/// Export the genesis wasm of the parachain.13	#[structopt(name = "export-genesis-wasm")]14	ExportGenesisWasm(ExportGenesisWasmCommand),1516	/// Build a chain specification.17	BuildSpec(sc_cli::BuildSpecCmd),1819	/// Validate blocks.20	CheckBlock(sc_cli::CheckBlockCmd),2122	/// Export blocks.23	ExportBlocks(sc_cli::ExportBlocksCmd),2425	/// Export the state of a given block into a chain spec.26	ExportState(sc_cli::ExportStateCmd),2728	/// Import blocks.29	ImportBlocks(sc_cli::ImportBlocksCmd),3031	/// Remove the whole chain.32	PurgeChain(cumulus_client_cli::PurgeChainCmd),3334	/// Revert the chain to a previous state.35	Revert(sc_cli::RevertCmd),3637	/// The custom benchmark subcommmand benchmarking runtime pallets.38	#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]39	Benchmark(frame_benchmarking_cli::BenchmarkCmd),40}4142/// Command for exporting the genesis state of the parachain43#[derive(Debug, StructOpt)]44pub struct ExportGenesisStateCommand {45	/// Output file name or stdout if unspecified.46	#[structopt(parse(from_os_str))]47	pub output: Option<PathBuf>,4849	/// Id of the parachain this state is for.50	///51	/// Default: 10052	#[structopt(long, conflicts_with = "chain")]53	pub parachain_id: Option<u32>,5455	/// Write output in binary. Default is to write in hex.56	#[structopt(short, long)]57	pub raw: bool,5859	/// The name of the chain for that the genesis state should be exported.60	#[structopt(long, conflicts_with = "parachain-id")]61	pub chain: Option<String>,62}6364/// Command for exporting the genesis wasm file.65#[derive(Debug, StructOpt)]66pub struct ExportGenesisWasmCommand {67	/// Output file name or stdout if unspecified.68	#[structopt(parse(from_os_str))]69	pub output: Option<PathBuf>,7071	/// Write output in binary. Default is to write in hex.72	#[structopt(short, long)]73	pub raw: bool,7475	/// The name of the chain for that the genesis wasm file should be exported.76	#[structopt(long)]77	pub chain: Option<String>,78}7980#[derive(Debug, StructOpt)]81#[structopt(settings = &[82	structopt::clap::AppSettings::GlobalVersion,83	structopt::clap::AppSettings::ArgsNegateSubcommands,84	structopt::clap::AppSettings::SubcommandsNegateReqs,85])]86pub struct Cli {87	#[structopt(subcommand)]88	pub subcommand: Option<Subcommand>,8990	#[structopt(flatten)]91	pub run: cumulus_client_cli::RunCmd,9293	/// Relaychain arguments94	#[structopt(raw = true)]95	pub relaychain_args: Vec<String>,96}9798#[derive(Debug)]99pub struct RelayChainCli {100	/// The actual relay chain cli object.101	pub base: polkadot_cli::RunCmd,102103	/// Optional chain id that should be passed to the relay chain.104	pub chain_id: Option<String>,105106	/// The base path that should be used by the relay chain.107	pub base_path: Option<PathBuf>,108}109110impl RelayChainCli {111	/// Parse the relay chain CLI parameters using the para chain `Configuration`.112	pub fn new<'a>(113		para_config: &sc_service::Configuration,114		relay_chain_args: impl Iterator<Item = &'a String>,115	) -> Self {116		let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);117		let chain_id = extension.map(|e| e.relay_chain.clone());118		let base_path = para_config119			.base_path120			.as_ref()121			.map(|x| x.path().join("polkadot"));122		Self {123			base_path,124			chain_id,125			base: polkadot_cli::RunCmd::from_iter(relay_chain_args),126		}127	}128}