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 #[clap(subcommand)]32 Key(sc_cli::KeySubcommand),3334 35 BuildSpec(sc_cli::BuildSpecCmd),3637 38 CheckBlock(sc_cli::CheckBlockCmd),3940 41 ExportBlocks(sc_cli::ExportBlocksCmd),4243 44 ExportState(sc_cli::ExportStateCmd),4546 47 ImportBlocks(sc_cli::ImportBlocksCmd),4849 50 PurgeChain(cumulus_client_cli::PurgeChainCmd),5152 53 Revert(sc_cli::RevertCmd),5455 56 #[clap(subcommand)]57 #[cfg(feature = "runtime-benchmarks")]58 Benchmark(frame_benchmarking_cli::BenchmarkCmd),5960 61 #[cfg(feature = "try-runtime")]62 TryRuntime(try_runtime_cli::TryRuntimeCmd),6364 65 #[cfg(not(feature = "try-runtime"))]66 TryRuntime,67}6869#[derive(Debug, Parser)]70#[clap(args_conflicts_with_subcommands = true, subcommand_negates_reqs = true)]71pub struct Cli {72 #[structopt(subcommand)]73 pub subcommand: Option<Subcommand>,7475 #[structopt(flatten)]76 pub run: cumulus_client_cli::RunCmd,7778 79 80 81 82 83 84 #[structopt(default_value = "500", long)]85 pub idle_autoseal_interval: u64,8687 88 89 90 91 92 93 94 #[clap(long)]95 pub no_hardware_benchmarks: bool,9697 98 #[structopt(raw = true)]99 pub relaychain_args: Vec<String>,100}101102impl Cli {103 pub fn node_name() -> String {104 "Unique".into()105 }106}107108#[derive(Debug)]109pub struct RelayChainCli {110 111 pub base: polkadot_cli::RunCmd,112113 114 pub chain_id: Option<String>,115116 117 pub base_path: Option<PathBuf>,118}119120impl RelayChainCli {121 122 pub fn new<'a>(123 para_config: &sc_service::Configuration,124 relay_chain_args: impl Iterator<Item = &'a String>,125 ) -> Self {126 let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);127 let chain_id = extension.map(|e| e.relay_chain.clone());128 let base_path = para_config129 .base_path130 .as_ref()131 .map(|x| x.path().join("polkadot"));132 Self {133 base_path,134 chain_id,135 base: polkadot_cli::RunCmd::parse_from(relay_chain_args),136 }137 }138}