referrerpolicy=no-referrer-when-downgrade

revive_dev_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::{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	/// Key management cli utilities
58	#[command(subcommand)]
59	Key(sc_cli::KeySubcommand),
60
61	/// Build a chain specification.
62	BuildSpec(sc_cli::BuildSpecCmd),
63
64	/// Validate blocks.
65	CheckBlock(sc_cli::CheckBlockCmd),
66
67	/// Export blocks.
68	ExportBlocks(sc_cli::ExportBlocksCmd),
69
70	/// Export the state of a given block into a chain spec.
71	ExportState(sc_cli::ExportStateCmd),
72
73	/// Import blocks.
74	ImportBlocks(sc_cli::ImportBlocksCmd),
75
76	/// Remove the whole chain.
77	PurgeChain(sc_cli::PurgeChainCmd),
78
79	/// Revert the chain to a previous state.
80	Revert(sc_cli::RevertCmd),
81
82	/// Db meta columns information.
83	ChainInfo(sc_cli::ChainInfoCmd),
84}