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

difftreelog

source

node/src/cli.rs3.5 KiBsourcehistory
1use crate::chain_spec;2use cumulus_client_cli;3use sc_cli;4use std::path::PathBuf;5use structopt::StructOpt;67/// Sub-commands supported by the collator.8#[derive(Debug, StructOpt)]9pub enum Subcommand {10	/// Export the genesis state of the parachain.11	#[structopt(name = "export-genesis-state")]12	ExportGenesisState(ExportGenesisStateCommand),1314	/// Export the genesis wasm of the parachain.15	#[structopt(name = "export-genesis-wasm")]16	ExportGenesisWasm(ExportGenesisWasmCommand),1718	/// Build a chain specification.19	BuildSpec(sc_cli::BuildSpecCmd),2021	/// Validate blocks.22	CheckBlock(sc_cli::CheckBlockCmd),2324	/// Export blocks.25	ExportBlocks(sc_cli::ExportBlocksCmd),2627	/// Export the state of a given block into a chain spec.28	ExportState(sc_cli::ExportStateCmd),2930	/// Import blocks.31	ImportBlocks(sc_cli::ImportBlocksCmd),3233	/// Remove the whole chain.34	PurgeChain(cumulus_client_cli::PurgeChainCmd),3536	/// Revert the chain to a previous state.37	Revert(sc_cli::RevertCmd),3839	/// The custom benchmark subcommmand benchmarking runtime pallets.40	#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]41	Benchmark(frame_benchmarking_cli::BenchmarkCmd),42}4344/// Command for exporting the genesis state of the parachain45#[derive(Debug, StructOpt)]46pub struct ExportGenesisStateCommand {47	/// Output file name or stdout if unspecified.48	#[structopt(parse(from_os_str))]49	pub output: Option<PathBuf>,5051	/// Id of the parachain this state is for.52	///53	/// Default: 10054	#[structopt(long, conflicts_with = "chain")]55	pub parachain_id: Option<u32>,5657	/// Write output in binary. Default is to write in hex.58	#[structopt(short, long)]59	pub raw: bool,6061	/// The name of the chain for that the genesis state should be exported.62	#[structopt(long, conflicts_with = "parachain-id")]63	pub chain: Option<String>,64}6566/// Command for exporting the genesis wasm file.67#[derive(Debug, StructOpt)]68pub struct ExportGenesisWasmCommand {69	/// Output file name or stdout if unspecified.70	#[structopt(parse(from_os_str))]71	pub output: Option<PathBuf>,7273	/// Write output in binary. Default is to write in hex.74	#[structopt(short, long)]75	pub raw: bool,7677	/// The name of the chain for that the genesis wasm file should be exported.78	#[structopt(long)]79	pub chain: Option<String>,80}8182#[derive(Debug, StructOpt)]83#[structopt(settings = &[84	structopt::clap::AppSettings::GlobalVersion,85	structopt::clap::AppSettings::ArgsNegateSubcommands,86	structopt::clap::AppSettings::SubcommandsNegateReqs,87])]88pub struct Cli {89	#[structopt(subcommand)]90	pub subcommand: Option<Subcommand>,9192	#[structopt(flatten)]93	pub run: cumulus_client_cli::RunCmd,9495	/// Relaychain arguments96	#[structopt(raw = true)]97	pub relaychain_args: Vec<String>,98}99100#[derive(Debug)]101pub struct RelayChainCli {102	/// The actual relay chain cli object.103	pub base: polkadot_cli::RunCmd,104105	/// Optional chain id that should be passed to the relay chain.106	pub chain_id: Option<String>,107108	/// The base path that should be used by the relay chain.109	pub base_path: Option<PathBuf>,110}111112impl RelayChainCli {113	/// Parse the relay chain CLI parameters using the para chain `Configuration`.114	pub fn new<'a>(115		para_config: &sc_service::Configuration,116		relay_chain_args: impl Iterator<Item = &'a String>,117	) -> Self {118		let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);119		let chain_id = extension.map(|e| e.relay_chain.clone());120		let base_path = para_config121			.base_path122			.as_ref()123			.map(|x| x.path().join("polkadot"));124		Self {125			base_path,126			chain_id,127			base: polkadot_cli::RunCmd::from_iter(relay_chain_args),128		}129	}130}