1234567891011121314151617use crate::chain_spec;18use std::path::PathBuf;19use clap::Parser;202122#[derive(Debug, Parser)]23pub enum Subcommand {24 25 ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand),2627 28 ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),2930 31 BuildSpec(sc_cli::BuildSpecCmd),3233 34 CheckBlock(sc_cli::CheckBlockCmd),3536 37 ExportBlocks(sc_cli::ExportBlocksCmd),3839 40 ExportState(sc_cli::ExportStateCmd),4142 43 ImportBlocks(sc_cli::ImportBlocksCmd),4445 46 PurgeChain(cumulus_client_cli::PurgeChainCmd),4748 49 Revert(sc_cli::RevertCmd),5051 52 #[clap(subcommand)]53 #[cfg(feature = "runtime-benchmarks")]54 Benchmark(frame_benchmarking_cli::BenchmarkCmd),5556 57 #[cfg(feature = "try-runtime")]58 TryRuntime(try_runtime_cli::TryRuntimeCmd),5960 61 #[cfg(not(feature = "try-runtime"))]62 TryRuntime,63}6465#[derive(Debug, Parser)]66#[clap(args_conflicts_with_subcommands = true, subcommand_negates_reqs = true)]67pub struct Cli {68 #[structopt(subcommand)]69 pub subcommand: Option<Subcommand>,7071 #[structopt(flatten)]72 pub run: cumulus_client_cli::RunCmd,7374 75 76 77 78 79 80 #[structopt(default_value = "500", long)]81 pub idle_autoseal_interval: u64,8283 84 85 86 87 88 89 90 #[clap(long)]91 pub no_hardware_benchmarks: bool,9293 94 #[structopt(raw = true)]95 pub relaychain_args: Vec<String>,96}9798impl Cli {99 pub fn node_name() -> String {100 "Unique".into()101 }102}103104#[derive(Debug)]105pub struct RelayChainCli {106 107 pub base: polkadot_cli::RunCmd,108109 110 pub chain_id: Option<String>,111112 113 pub base_path: Option<PathBuf>,114}115116impl RelayChainCli {117 118 pub fn new<'a>(119 para_config: &sc_service::Configuration,120 relay_chain_args: impl Iterator<Item = &'a String>,121 ) -> Self {122 let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);123 let chain_id = extension.map(|e| e.relay_chain.clone());124 let base_path = para_config125 .base_path126 .as_ref()127 .map(|x| x.path().join("polkadot"));128 Self {129 base_path,130 chain_id,131 base: polkadot_cli::RunCmd::parse_from(relay_chain_args),132 }133 }134}