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 #[structopt(long)]89 pub disable_autoseal_on_tx: bool,9091 92 93 94 95 96 97 98 #[clap(long)]99 pub no_hardware_benchmarks: bool,100101 102 #[structopt(raw = true)]103 pub relaychain_args: Vec<String>,104}105106impl Cli {107 pub fn node_name() -> String {108 "Unique".into()109 }110}111112#[derive(Debug)]113pub struct RelayChainCli {114 115 pub base: polkadot_cli::RunCmd,116117 118 pub chain_id: Option<String>,119120 121 pub base_path: PathBuf,122}123124impl RelayChainCli {125 126 pub fn new<'a>(127 para_config: &sc_service::Configuration,128 relay_chain_args: impl Iterator<Item = &'a String>,129 ) -> Self {130 let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);131 let chain_id = extension.map(|e| e.relay_chain.clone());132 let base_path = para_config.base_path.path().join("polkadot");133 Self {134 base_path,135 chain_id,136 base: polkadot_cli::RunCmd::parse_from(relay_chain_args),137 }138 }139}