use clap::Parser;
use sc_cli::SubstrateCli;
use std::path::PathBuf;
#[derive(Debug, Parser)]
pub enum Subcommand {
#[command(name = "export-genesis-state")]
ExportGenesisState(ExportGenesisHeadCommand),
#[command(name = "export-genesis-wasm")]
ExportGenesisWasm(ExportGenesisWasmCommand),
}
#[derive(Debug, Parser)]
pub struct ExportGenesisHeadCommand {
#[arg()]
pub output: Option<PathBuf>,
#[arg(long, default_value_t = 100)]
pub parachain_id: u32,
#[arg(long, default_value_t = 1024)]
pub pov_size: usize,
#[arg(long, default_value_t = 1)]
pub pvf_complexity: u32,
}
#[derive(Debug, Parser)]
pub struct ExportGenesisWasmCommand {
#[arg()]
pub output: Option<PathBuf>,
}
#[allow(missing_docs)]
#[derive(Debug, Parser)]
#[group(skip)]
pub struct RunCmd {
#[allow(missing_docs)]
#[clap(flatten)]
pub base: sc_cli::RunCmd,
#[arg(long, default_value_t = 2000)]
pub parachain_id: u32,
#[arg(long, default_value_t = 1024)]
pub pov_size: usize,
#[arg(long, default_value_t = 1)]
pub pvf_complexity: u32,
}
#[allow(missing_docs)]
#[derive(Debug, Parser)]
pub struct Cli {
#[command(subcommand)]
pub subcommand: Option<Subcommand>,
#[clap(flatten)]
pub run: RunCmd,
}
impl SubstrateCli for Cli {
fn impl_name() -> String {
"Parity Zombienet/Undying".into()
}
fn impl_version() -> String {
env!("CARGO_PKG_VERSION").into()
}
fn description() -> String {
env!("CARGO_PKG_DESCRIPTION").into()
}
fn author() -> String {
env!("CARGO_PKG_AUTHORS").into()
}
fn support_url() -> String {
"https://github.com/paritytech/polkadot-sdk/issues/new".into()
}
fn copyright_start_year() -> i32 {
2022
}
fn executable_name() -> String {
"undying-collator".into()
}
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
let id = if id.is_empty() { "rococo" } else { id };
Ok(match id {
"rococo-staging" =>
Box::new(polkadot_service::chain_spec::rococo_staging_testnet_config()?),
"rococo-local" =>
Box::new(polkadot_service::chain_spec::rococo_local_testnet_config()?),
"rococo" => Box::new(polkadot_service::chain_spec::rococo_config()?),
path => {
let path = std::path::PathBuf::from(path);
Box::new(polkadot_service::RococoChainSpec::from_json_file(path)?)
},
})
}
}