1// This file is part of Substrate.
23// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
56// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
1718use polkadot_sdk::*;
1920#[derive(Debug, Clone)]
21pub enum Consensus {
22 ManualSeal(u64),
23 InstantSeal,
24None,
25}
2627impl std::str::FromStr for Consensus {
28type Err = String;
2930fn from_str(s: &str) -> Result<Self, Self::Err> {
31Ok(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 {
38return Err("incorrect consensus identifier".into());
39 })
40 }
41}
4243#[derive(Debug, clap::Parser)]
44pub struct Cli {
45#[command(subcommand)]
46pub subcommand: Option<Subcommand>,
4748#[clap(long, default_value = "manual-seal-3000")]
49pub consensus: Consensus,
5051#[clap(flatten)]
52pub run: sc_cli::RunCmd,
53}
5455#[derive(Debug, clap::Subcommand)]
56pub enum Subcommand {
57/// Key management cli utilities
58#[command(subcommand)]
59Key(sc_cli::KeySubcommand),
6061/// Build a chain specification.
62 /// DEPRECATED: `build-spec` command will be removed after 1/04/2026. Use `export-chain-spec`
63 /// command instead.
64#[deprecated(
65 note = "build-spec command will be removed after 1/04/2026. Use export-chain-spec command instead"
66)]
67BuildSpec(sc_cli::BuildSpecCmd),
6869/// Export the chain specification.
70ExportChainSpec(sc_cli::ExportChainSpecCmd),
7172/// Validate blocks.
73CheckBlock(sc_cli::CheckBlockCmd),
7475/// Export blocks.
76ExportBlocks(sc_cli::ExportBlocksCmd),
7778/// Export the state of a given block into a chain spec.
79ExportState(sc_cli::ExportStateCmd),
8081/// Import blocks.
82ImportBlocks(sc_cli::ImportBlocksCmd),
8384/// Remove the whole chain.
85PurgeChain(sc_cli::PurgeChainCmd),
8687/// Revert the chain to a previous state.
88Revert(sc_cli::RevertCmd),
8990/// Db meta columns information.
91ChainInfo(sc_cli::ChainInfoCmd),
92}