1use crate::chain_spec;2use std::path::PathBuf;3use structopt::StructOpt;456#[derive(Debug, StructOpt)]7pub enum Subcommand {8 9 #[structopt(name = "export-genesis-state")]10 ExportGenesisState(ExportGenesisStateCommand),1112 13 #[structopt(name = "export-genesis-wasm")]14 ExportGenesisWasm(ExportGenesisWasmCommand),1516 17 BuildSpec(sc_cli::BuildSpecCmd),1819 20 CheckBlock(sc_cli::CheckBlockCmd),2122 23 ExportBlocks(sc_cli::ExportBlocksCmd),2425 26 ExportState(sc_cli::ExportStateCmd),2728 29 ImportBlocks(sc_cli::ImportBlocksCmd),3031 32 PurgeChain(cumulus_client_cli::PurgeChainCmd),3334 35 Revert(sc_cli::RevertCmd),3637 38 #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]39 Benchmark(frame_benchmarking_cli::BenchmarkCmd),40}414243#[derive(Debug, StructOpt)]44pub struct ExportGenesisStateCommand {45 46 #[structopt(parse(from_os_str))]47 pub output: Option<PathBuf>,4849 50 51 52 #[structopt(long, conflicts_with = "chain")]53 pub parachain_id: Option<u32>,5455 56 #[structopt(short, long)]57 pub raw: bool,5859 60 #[structopt(long, conflicts_with = "parachain-id")]61 pub chain: Option<String>,62}636465#[derive(Debug, StructOpt)]66pub struct ExportGenesisWasmCommand {67 68 #[structopt(parse(from_os_str))]69 pub output: Option<PathBuf>,7071 72 #[structopt(short, long)]73 pub raw: bool,7475 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 94 #[structopt(raw = true)]95 pub relaychain_args: Vec<String>,96}9798#[derive(Debug)]99pub struct RelayChainCli {100 101 pub base: polkadot_cli::RunCmd,102103 104 pub chain_id: Option<String>,105106 107 pub base_path: Option<PathBuf>,108}109110impl RelayChainCli {111 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}