1use crate::{ExportMetadataCmd, ExportRuntimeVersionCmd};
6use std::path::PathBuf;
7
8#[cfg(feature = "frequency-no-relay")]
9use std::num::NonZeroU16;
10
11#[cfg(feature = "frequency-no-relay")]
12use cli_opt::SealingMode;
13
14#[derive(Debug, clap::Subcommand)]
16pub enum Subcommand {
17	#[command(subcommand)]
19	Key(sc_cli::KeySubcommand),
20	BuildSpec(sc_cli::BuildSpecCmd),
22
23	CheckBlock(sc_cli::CheckBlockCmd),
25
26	ExportBlocks(sc_cli::ExportBlocksCmd),
28
29	ExportState(sc_cli::ExportStateCmd),
31
32	ImportBlocks(sc_cli::ImportBlocksCmd),
34
35	ExportMetadata(ExportMetadataCmd),
37
38	Revert(sc_cli::RevertCmd),
40
41	PurgeChain(cumulus_client_cli::PurgeChainCmd),
43
44	#[command(alias = "export-genesis-state")]
46	ExportGenesisHead(cumulus_client_cli::ExportGenesisHeadCommand),
47
48	ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),
50
51	#[clap(subcommand)]
54	Benchmark(frame_benchmarking_cli::BenchmarkCmd),
55
56	ExportRuntimeVersion(ExportRuntimeVersionCmd),
58}
59
60#[derive(Debug, clap::Parser)]
61#[clap(
62	propagate_version = true,
63	args_conflicts_with_subcommands = true,
64	subcommand_negates_reqs = true
65)]
66pub struct Cli {
67	#[clap(subcommand)]
68	pub subcommand: Option<Subcommand>,
69
70	#[clap(flatten)]
71	pub run: cumulus_client_cli::RunCmd,
72
73	#[clap(long)]
81	pub no_hardware_benchmarks: bool,
82
83	#[clap(raw = true)]
85	pub relay_chain_args: Vec<String>,
86
87	#[cfg(feature = "frequency-no-relay")]
91	#[clap(long, value_enum, help = "The sealing mode", default_value_t=SealingMode::Instant)]
92	pub sealing: SealingMode,
93
94	#[cfg(feature = "frequency-no-relay")]
96	#[clap(long, help = "The interval in seconds", default_value = "6", value_name = "SECONDS")]
97	pub sealing_interval: NonZeroU16,
98
99	#[cfg(feature = "frequency-no-relay")]
101	#[clap(long, help = "Create empty blocks in interval sealing modes", default_value = "false")]
102	pub sealing_create_empty_blocks: bool,
103}
104
105#[derive(Debug)]
106pub struct RelayChainCli {
107	pub base: polkadot_cli::RunCmd,
109
110	pub chain_id: Option<String>,
112
113	pub base_path: Option<PathBuf>,
115}
116
117impl RelayChainCli {
118	pub fn new<'a>(
120		para_config: &sc_service::Configuration,
121		relay_chain_args: impl Iterator<Item = &'a String>,
122	) -> Self {
123		let extension =
124			frequency_service::chain_spec::Extensions::try_get(&*para_config.chain_spec);
125		let chain_id = extension.map(|e| e.relay_chain.clone());
126		let base_path = para_config.base_path.path().join("polkadot");
127		Self {
128			base_path: Some(base_path),
129			chain_id,
130			base: clap::Parser::parse_from(relay_chain_args),
131		}
132	}
133}