1use clap::Parser;
20use sc_cli::SubstrateCli;
21use std::path::PathBuf;
22
23#[derive(Debug, Parser)]
25pub enum Subcommand {
26 #[command(name = "export-genesis-state")]
28 ExportGenesisState(ExportGenesisHeadCommand),
29
30 #[command(name = "export-genesis-wasm")]
32 ExportGenesisWasm(ExportGenesisWasmCommand),
33}
34
35#[derive(Debug, Parser)]
37pub struct ExportGenesisHeadCommand {
38 #[arg()]
40 pub output: Option<PathBuf>,
41}
42
43#[derive(Debug, Parser)]
45pub struct ExportGenesisWasmCommand {
46 #[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 #[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}