difftreelog
feat add key subcommand
in: master
2 files changed
node/cli/src/cli.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use crate::chain_spec;18use std::path::PathBuf;19use clap::Parser;2021/// Sub-commands supported by the collator.22#[derive(Debug, Parser)]23pub enum Subcommand {24 /// Export the genesis state of the parachain.25 ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand),2627 /// Export the genesis wasm of the parachain.28 ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),2930 /// Build a chain specification.31 BuildSpec(sc_cli::BuildSpecCmd),3233 /// Validate blocks.34 CheckBlock(sc_cli::CheckBlockCmd),3536 /// Export blocks.37 ExportBlocks(sc_cli::ExportBlocksCmd),3839 /// Export the state of a given block into a chain spec.40 ExportState(sc_cli::ExportStateCmd),4142 /// Import blocks.43 ImportBlocks(sc_cli::ImportBlocksCmd),4445 /// Remove the whole chain.46 PurgeChain(cumulus_client_cli::PurgeChainCmd),4748 /// Revert the chain to a previous state.49 Revert(sc_cli::RevertCmd),5051 /// The custom benchmark subcommmand benchmarking runtime pallets.52 #[clap(subcommand)]53 #[cfg(feature = "runtime-benchmarks")]54 Benchmark(frame_benchmarking_cli::BenchmarkCmd),5556 /// Try runtime57 #[cfg(feature = "try-runtime")]58 TryRuntime(try_runtime_cli::TryRuntimeCmd),5960 /// Try runtime. Note: `try-runtime` feature must be enabled.61 #[cfg(not(feature = "try-runtime"))]62 TryRuntime,63}6465#[derive(Debug, Parser)]66#[clap(args_conflicts_with_subcommands = true, subcommand_negates_reqs = true)]67pub struct Cli {68 #[structopt(subcommand)]69 pub subcommand: Option<Subcommand>,7071 #[structopt(flatten)]72 pub run: cumulus_client_cli::RunCmd,7374 /// When running the node in the `--dev` mode and75 /// there is no transaction in the transaction pool,76 /// an empty block will be sealed automatically77 /// after the `--idle-autoseal-interval` milliseconds.78 ///79 /// The default interval is 500 milliseconds80 #[structopt(default_value = "500", long)]81 pub idle_autoseal_interval: u64,8283 /// Disable automatic hardware benchmarks.84 ///85 /// By default these benchmarks are automatically ran at startup and measure86 /// the CPU speed, the memory bandwidth and the disk speed.87 ///88 /// The results are then printed out in the logs, and also sent as part of89 /// telemetry, if telemetry is enabled.90 #[clap(long)]91 pub no_hardware_benchmarks: bool,9293 /// Relaychain arguments94 #[structopt(raw = true)]95 pub relaychain_args: Vec<String>,96}9798impl Cli {99 pub fn node_name() -> String {100 "Unique".into()101 }102}103104#[derive(Debug)]105pub struct RelayChainCli {106 /// The actual relay chain cli object.107 pub base: polkadot_cli::RunCmd,108109 /// Optional chain id that should be passed to the relay chain.110 pub chain_id: Option<String>,111112 /// The base path that should be used by the relay chain.113 pub base_path: Option<PathBuf>,114}115116impl RelayChainCli {117 /// Parse the relay chain CLI parameters using the para chain `Configuration`.118 pub fn new<'a>(119 para_config: &sc_service::Configuration,120 relay_chain_args: impl Iterator<Item = &'a String>,121 ) -> Self {122 let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);123 let chain_id = extension.map(|e| e.relay_chain.clone());124 let base_path = para_config125 .base_path126 .as_ref()127 .map(|x| x.path().join("polkadot"));128 Self {129 base_path,130 chain_id,131 base: polkadot_cli::RunCmd::parse_from(relay_chain_args),132 }133 }134}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use crate::chain_spec;18use std::path::PathBuf;19use clap::Parser;2021/// Sub-commands supported by the collator.22#[derive(Debug, Parser)]23pub enum Subcommand {24 /// Export the genesis state of the parachain.25 ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand),2627 /// Export the genesis wasm of the parachain.28 ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),2930 /// Keys manipulation subcommand31 #[clap(subcommand)]32 Key(sc_cli::KeySubcommand),3334 /// Build a chain specification.35 BuildSpec(sc_cli::BuildSpecCmd),3637 /// Validate blocks.38 CheckBlock(sc_cli::CheckBlockCmd),3940 /// Export blocks.41 ExportBlocks(sc_cli::ExportBlocksCmd),4243 /// Export the state of a given block into a chain spec.44 ExportState(sc_cli::ExportStateCmd),4546 /// Import blocks.47 ImportBlocks(sc_cli::ImportBlocksCmd),4849 /// Remove the whole chain.50 PurgeChain(cumulus_client_cli::PurgeChainCmd),5152 /// Revert the chain to a previous state.53 Revert(sc_cli::RevertCmd),5455 /// The custom benchmark subcommmand benchmarking runtime pallets.56 #[clap(subcommand)]57 #[cfg(feature = "runtime-benchmarks")]58 Benchmark(frame_benchmarking_cli::BenchmarkCmd),5960 /// Try runtime61 #[cfg(feature = "try-runtime")]62 TryRuntime(try_runtime_cli::TryRuntimeCmd),6364 /// Try runtime. Note: `try-runtime` feature must be enabled.65 #[cfg(not(feature = "try-runtime"))]66 TryRuntime,67}6869#[derive(Debug, Parser)]70#[clap(args_conflicts_with_subcommands = true, subcommand_negates_reqs = true)]71pub struct Cli {72 #[structopt(subcommand)]73 pub subcommand: Option<Subcommand>,7475 #[structopt(flatten)]76 pub run: cumulus_client_cli::RunCmd,7778 /// When running the node in the `--dev` mode and79 /// there is no transaction in the transaction pool,80 /// an empty block will be sealed automatically81 /// after the `--idle-autoseal-interval` milliseconds.82 ///83 /// The default interval is 500 milliseconds84 #[structopt(default_value = "500", long)]85 pub idle_autoseal_interval: u64,8687 /// Disable automatic hardware benchmarks.88 ///89 /// By default these benchmarks are automatically ran at startup and measure90 /// the CPU speed, the memory bandwidth and the disk speed.91 ///92 /// The results are then printed out in the logs, and also sent as part of93 /// telemetry, if telemetry is enabled.94 #[clap(long)]95 pub no_hardware_benchmarks: bool,9697 /// Relaychain arguments98 #[structopt(raw = true)]99 pub relaychain_args: Vec<String>,100}101102impl Cli {103 pub fn node_name() -> String {104 "Unique".into()105 }106}107108#[derive(Debug)]109pub struct RelayChainCli {110 /// The actual relay chain cli object.111 pub base: polkadot_cli::RunCmd,112113 /// Optional chain id that should be passed to the relay chain.114 pub chain_id: Option<String>,115116 /// The base path that should be used by the relay chain.117 pub base_path: Option<PathBuf>,118}119120impl RelayChainCli {121 /// Parse the relay chain CLI parameters using the para chain `Configuration`.122 pub fn new<'a>(123 para_config: &sc_service::Configuration,124 relay_chain_args: impl Iterator<Item = &'a String>,125 ) -> Self {126 let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);127 let chain_id = extension.map(|e| e.relay_chain.clone());128 let base_path = para_config129 .base_path130 .as_ref()131 .map(|x| x.path().join("polkadot"));132 Self {133 base_path,134 chain_id,135 base: polkadot_cli::RunCmd::parse_from(relay_chain_args),136 }137 }138}node/cli/src/command.rsdiffbeforeafterboth--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -313,6 +313,7 @@
let cli = Cli::from_args();
match &cli.subcommand {
+ Some(Subcommand::Key(cmd)) => cmd.run(&cli),
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))