use crate::{ExportMetadataCmd, ExportRuntimeVersionCmd};
use std::path::PathBuf;
#[cfg(feature = "frequency-no-relay")]
use std::num::NonZeroU16;
#[cfg(feature = "frequency-no-relay")]
use cli_opt::SealingMode;
#[derive(Debug, clap::Subcommand)]
pub enum Subcommand {
#[command(subcommand)]
Key(sc_cli::KeySubcommand),
BuildSpec(sc_cli::BuildSpecCmd),
CheckBlock(sc_cli::CheckBlockCmd),
ExportBlocks(sc_cli::ExportBlocksCmd),
ExportState(sc_cli::ExportStateCmd),
ImportBlocks(sc_cli::ImportBlocksCmd),
ExportMetadata(ExportMetadataCmd),
Revert(sc_cli::RevertCmd),
PurgeChain(cumulus_client_cli::PurgeChainCmd),
#[command(alias = "export-genesis-state")]
ExportGenesisHead(cumulus_client_cli::ExportGenesisHeadCommand),
ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),
#[clap(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
ExportRuntimeVersion(ExportRuntimeVersionCmd),
}
#[derive(Debug, clap::Parser)]
#[clap(
propagate_version = true,
args_conflicts_with_subcommands = true,
subcommand_negates_reqs = true
)]
pub struct Cli {
#[clap(subcommand)]
pub subcommand: Option<Subcommand>,
#[clap(flatten)]
pub run: cumulus_client_cli::RunCmd,
#[clap(long)]
pub no_hardware_benchmarks: bool,
#[clap(raw = true)]
pub relay_chain_args: Vec<String>,
#[cfg(feature = "frequency-no-relay")]
#[clap(long, value_enum, help = "The sealing mode", default_value_t=SealingMode::Instant)]
pub sealing: SealingMode,
#[cfg(feature = "frequency-no-relay")]
#[clap(long, help = "The interval in seconds", default_value = "6", value_name = "SECONDS")]
pub sealing_interval: NonZeroU16,
#[cfg(feature = "frequency-no-relay")]
#[clap(long, help = "Create empty blocks in interval sealing modes", default_value = "false")]
pub sealing_create_empty_blocks: bool,
}
#[derive(Debug)]
pub struct RelayChainCli {
pub base: polkadot_cli::RunCmd,
pub chain_id: Option<String>,
pub base_path: Option<PathBuf>,
}
impl RelayChainCli {
pub fn new<'a>(
para_config: &sc_service::Configuration,
relay_chain_args: impl Iterator<Item = &'a String>,
) -> Self {
let extension =
frequency_service::chain_spec::Extensions::try_get(&*para_config.chain_spec);
let chain_id = extension.map(|e| e.relay_chain.clone());
let base_path = para_config.base_path.path().join("polkadot");
Self {
base_path: Some(base_path),
chain_id,
base: clap::Parser::parse_from(relay_chain_args),
}
}
}