referrerpolicy=no-referrer-when-downgrade

minimal_template_node/
cli.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// 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.
17
18use polkadot_sdk::*;
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 = "manual-seal-3000")]
49	pub consensus: Consensus,
50
51	#[clap(flatten)]
52	pub run: sc_cli::RunCmd,
53}
54
55#[derive(Debug, clap::Subcommand)]
56pub enum Subcommand {
57	/// Key management cli utilities
58	#[command(subcommand)]
59	Key(sc_cli::KeySubcommand),
60
61	/// 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	)]
67	BuildSpec(sc_cli::BuildSpecCmd),
68
69	/// Export the chain specification.
70	ExportChainSpec(sc_cli::ExportChainSpecCmd),
71
72	/// Validate blocks.
73	CheckBlock(sc_cli::CheckBlockCmd),
74
75	/// Export blocks.
76	ExportBlocks(sc_cli::ExportBlocksCmd),
77
78	/// Export the state of a given block into a chain spec.
79	ExportState(sc_cli::ExportStateCmd),
80
81	/// Import blocks.
82	ImportBlocks(sc_cli::ImportBlocksCmd),
83
84	/// Remove the whole chain.
85	PurgeChain(sc_cli::PurgeChainCmd),
86
87	/// Revert the chain to a previous state.
88	Revert(sc_cli::RevertCmd),
89
90	/// Db meta columns information.
91	ChainInfo(sc_cli::ChainInfoCmd),
92}