1use polkadot_sdk::{sc_cli::RunCmd, *};
19
20#[derive(Debug, Clone)]
21pub enum Consensus {
22 ManualSeal(u64),
23 InstantSeal,
24 None,
25}
26
27impl std::str::FromStr for Consensus {
28 type Err = String;
29
30 fn from_str(s: &str) -> Result<Self, Self::Err> {
31 Ok(if s == "instant-seal" {
32 Consensus::InstantSeal
33 } else if let Some(block_time) = s.strip_prefix("manual-seal-") {
34 Consensus::ManualSeal(block_time.parse().map_err(|_| "invalid block time")?)
35 } else if s.to_lowercase() == "none" {
36 Consensus::None
37 } else {
38 return Err("incorrect consensus identifier".into());
39 })
40 }
41}
42
43#[derive(Debug, clap::Parser)]
44pub struct Cli {
45 #[command(subcommand)]
46 pub subcommand: Option<Subcommand>,
47
48 #[clap(long, default_value = "instant-seal")]
49 pub consensus: Consensus,
50
51 #[clap(flatten)]
52 pub run: RunCmd,
53}
54
55#[derive(Debug, clap::Subcommand)]
56pub enum Subcommand {
57 #[command(subcommand)]
59 Key(sc_cli::KeySubcommand),
60
61 BuildSpec(sc_cli::BuildSpecCmd),
63
64 CheckBlock(sc_cli::CheckBlockCmd),
66
67 ExportBlocks(sc_cli::ExportBlocksCmd),
69
70 ExportState(sc_cli::ExportStateCmd),
72
73 ImportBlocks(sc_cli::ImportBlocksCmd),
75
76 PurgeChain(sc_cli::PurgeChainCmd),
78
79 Revert(sc_cli::RevertCmd),
81
82 ChainInfo(sc_cli::ChainInfoCmd),
84}