referrerpolicy=no-referrer-when-downgrade

adder_collator/
cli.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
16
17//! Polkadot CLI library.
18
19use clap::Parser;
20use sc_cli::SubstrateCli;
21use std::path::PathBuf;
22
23/// Sub-commands supported by the collator.
24#[derive(Debug, Parser)]
25pub enum Subcommand {
26	/// Export the genesis state of the parachain.
27	#[command(name = "export-genesis-state")]
28	ExportGenesisState(ExportGenesisHeadCommand),
29
30	/// Export the genesis wasm of the parachain.
31	#[command(name = "export-genesis-wasm")]
32	ExportGenesisWasm(ExportGenesisWasmCommand),
33}
34
35/// Command for exporting the genesis head data of the parachain
36#[derive(Debug, Parser)]
37pub struct ExportGenesisHeadCommand {
38	/// Output file name or stdout if unspecified.
39	#[arg()]
40	pub output: Option<PathBuf>,
41}
42
43/// Command for exporting the genesis wasm file.
44#[derive(Debug, Parser)]
45pub struct ExportGenesisWasmCommand {
46	/// Output file name or stdout if unspecified.
47	#[arg()]
48	pub output: Option<PathBuf>,
49}
50
51#[allow(missing_docs)]
52#[derive(Debug, Parser)]
53#[group(skip)]
54pub struct RunCmd {
55	#[allow(missing_docs)]
56	#[clap(flatten)]
57	pub base: sc_cli::RunCmd,
58
59	/// Id of the parachain this collator collates for.
60	#[arg(long)]
61	pub parachain_id: Option<u32>,
62}
63
64#[allow(missing_docs)]
65#[derive(Debug, Parser)]
66pub struct Cli {
67	#[command(subcommand)]
68	pub subcommand: Option<Subcommand>,
69
70	#[clap(flatten)]
71	pub run: RunCmd,
72}
73
74impl SubstrateCli for Cli {
75	fn impl_name() -> String {
76		"Parity Polkadot".into()
77	}
78
79	fn impl_version() -> String {
80		"0.0.0".into()
81	}
82
83	fn description() -> String {
84		env!("CARGO_PKG_DESCRIPTION").into()
85	}
86
87	fn author() -> String {
88		env!("CARGO_PKG_AUTHORS").into()
89	}
90
91	fn support_url() -> String {
92		"https://github.com/paritytech/polkadot-sdk/issues/new".into()
93	}
94
95	fn copyright_start_year() -> i32 {
96		2017
97	}
98
99	fn executable_name() -> String {
100		"adder-collator".into()
101	}
102
103	fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
104		let id = if id.is_empty() { "rococo" } else { id };
105		Ok(match id {
106			"rococo-staging" =>
107				Box::new(polkadot_service::chain_spec::rococo_staging_testnet_config()?),
108			"rococo-local" =>
109				Box::new(polkadot_service::chain_spec::rococo_local_testnet_config()?),
110			"rococo" => Box::new(polkadot_service::chain_spec::rococo_config()?),
111			path => {
112				let path = std::path::PathBuf::from(path);
113				Box::new(polkadot_service::RococoChainSpec::from_json_file(path)?)
114			},
115		})
116	}
117}