Companion for substrate#10632 (#895)

* Companion for substrate#10632

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* cargo update -p clap

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Update substrate

* update lockfile for {"polkadot"}

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Qinxuan Chen
2022-01-25 19:42:59 +08:00
committed by GitHub
parent a9eb032086
commit fd145766d4
7 changed files with 371 additions and 354 deletions
+1 -1
View File
@@ -10,10 +10,10 @@ name = "polkadot-collator"
path = "src/main.rs"
[dependencies]
clap = { version = "3.0", features = ["derive"] }
futures = { version = "0.3.1", features = ["compat"] }
log = "0.4.8"
codec = { package = "parity-scale-codec", version = "2.3.0" }
structopt = "0.3.3"
serde = { version = "1.0.132", features = ["derive"] }
hex-literal = "0.2.1"
async-trait = "0.1.42"
+25 -24
View File
@@ -15,19 +15,19 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::chain_spec;
use clap::{AppSettings, Parser};
use sc_cli;
use std::path::PathBuf;
use structopt::StructOpt;
/// Sub-commands supported by the collator.
#[derive(Debug, StructOpt)]
#[derive(Debug, clap::Subcommand)]
pub enum Subcommand {
/// Export the genesis state of the parachain.
#[structopt(name = "export-genesis-state")]
#[clap(name = "export-genesis-state")]
ExportGenesisState(ExportGenesisStateCommand),
/// Export the genesis wasm of the parachain.
#[structopt(name = "export-genesis-wasm")]
#[clap(name = "export-genesis-wasm")]
ExportGenesisWasm(ExportGenesisWasmCommand),
/// Build a chain specification.
@@ -52,69 +52,70 @@ pub enum Subcommand {
Revert(sc_cli::RevertCmd),
/// The custom benchmark subcommmand benchmarking runtime pallets.
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
#[clap(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
/// Try some testing command against a specified runtime state.
TryRuntime(try_runtime_cli::TryRuntimeCmd),
/// Key management CLI utilities
#[clap(subcommand)]
Key(sc_cli::KeySubcommand),
}
/// Command for exporting the genesis state of the parachain
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct ExportGenesisStateCommand {
/// Output file name or stdout if unspecified.
#[structopt(parse(from_os_str))]
#[clap(parse(from_os_str))]
pub output: Option<PathBuf>,
/// Id of the parachain this state is for.
///
/// Default: 100
#[structopt(long)]
#[clap(long)]
pub parachain_id: Option<u32>,
/// Write output in binary. Default is to write in hex.
#[structopt(short, long)]
#[clap(short, long)]
pub raw: bool,
/// The name of the chain for that the genesis state should be exported.
#[structopt(long)]
#[clap(long)]
pub chain: Option<String>,
}
/// Command for exporting the genesis wasm file.
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct ExportGenesisWasmCommand {
/// Output file name or stdout if unspecified.
#[structopt(parse(from_os_str))]
#[clap(parse(from_os_str))]
pub output: Option<PathBuf>,
/// Write output in binary. Default is to write in hex.
#[structopt(short, long)]
#[clap(short, long)]
pub raw: bool,
/// The name of the chain for that the genesis wasm file should be exported.
#[structopt(long)]
#[clap(long)]
pub chain: Option<String>,
}
#[derive(Debug, StructOpt)]
#[structopt(settings = &[
structopt::clap::AppSettings::GlobalVersion,
structopt::clap::AppSettings::ArgsNegateSubcommands,
structopt::clap::AppSettings::SubcommandsNegateReqs,
])]
#[derive(Debug, Parser)]
#[clap(setting(
AppSettings::PropagateVersion |
AppSettings::ArgsNegateSubcommands |
AppSettings::SubcommandsNegateReqs
))]
pub struct Cli {
#[structopt(subcommand)]
#[clap(subcommand)]
pub subcommand: Option<Subcommand>,
#[structopt(flatten)]
#[clap(flatten)]
pub run: cumulus_client_cli::RunCmd,
/// Relay chain arguments
#[structopt(raw = true)]
#[clap(raw = true)]
pub relaychain_args: Vec<String>,
}
@@ -139,6 +140,6 @@ impl RelayChainCli {
let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);
let chain_id = extension.map(|e| e.relay_chain.clone());
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot"));
Self { base_path, chain_id, base: polkadot_cli::RunCmd::from_iter(relay_chain_args) }
Self { base_path, chain_id, base: polkadot_cli::RunCmd::parse_from(relay_chain_args) }
}
}