1use crate::chain_spec;2use cumulus_client_cli;3use sc_cli;4use std::path::PathBuf;5use structopt::StructOpt;678#[derive(Debug, StructOpt)]9pub enum Subcommand {10 11 #[structopt(name = "export-genesis-state")]12 ExportGenesisState(ExportGenesisStateCommand),1314 15 #[structopt(name = "export-genesis-wasm")]16 ExportGenesisWasm(ExportGenesisWasmCommand),1718 19 BuildSpec(sc_cli::BuildSpecCmd),2021 22 CheckBlock(sc_cli::CheckBlockCmd),2324 25 ExportBlocks(sc_cli::ExportBlocksCmd),2627 28 ExportState(sc_cli::ExportStateCmd),2930 31 ImportBlocks(sc_cli::ImportBlocksCmd),3233 34 PurgeChain(cumulus_client_cli::PurgeChainCmd),3536 37 Revert(sc_cli::RevertCmd),3839 40 #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]41 Benchmark(frame_benchmarking_cli::BenchmarkCmd),42}434445#[derive(Debug, StructOpt)]46pub struct ExportGenesisStateCommand {47 48 #[structopt(parse(from_os_str))]49 pub output: Option<PathBuf>,5051 52 53 54 #[structopt(long, conflicts_with = "chain")]55 pub parachain_id: Option<u32>,5657 58 #[structopt(short, long)]59 pub raw: bool,6061 62 #[structopt(long, conflicts_with = "parachain-id")]63 pub chain: Option<String>,64}656667#[derive(Debug, StructOpt)]68pub struct ExportGenesisWasmCommand {69 70 #[structopt(parse(from_os_str))]71 pub output: Option<PathBuf>,7273 74 #[structopt(short, long)]75 pub raw: bool,7677 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 96 #[structopt(raw = true)]97 pub relaychain_args: Vec<String>,98}99100#[derive(Debug)]101pub struct RelayChainCli {102 103 pub base: polkadot_cli::RunCmd,104105 106 pub chain_id: Option<String>,107108 109 pub base_path: Option<PathBuf>,110}111112impl RelayChainCli {113 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}