From 83f5895b0ccc1ae3d0f27f849642a9959bd13e51 Mon Sep 17 00:00:00 2001 From: Guantong <04637@163.com> Date: Mon, 16 May 2022 13:51:04 +0800 Subject: [PATCH] Revert paritytech/cumulus#895 --- Cargo.toml | 2 +- src/cli.rs | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1d3309d6..8201e4d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,12 +40,12 @@ runtime-benchmarks = [ # crates.io array-bytes = { version = "1.5" } async-trait = { version = "0.1" } +clap = { version = "3.0", features = ["derive"] } codec = { package = "parity-scale-codec", version = "2.3" } futures = { version = "0.3" } jsonrpc-core = { version = "18.0" } log = { version = "0.4" } serde = { version = "1.0", features = ["derive"] } -structopt = { version = "0.3" } tempfile = { version = "3.2" } # parachain diff --git a/src/cli.rs b/src/cli.rs index a91e8dfc..479cbb61 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -19,19 +19,19 @@ // --- std --- use std::path::PathBuf; // --- crates.io --- -use structopt::StructOpt; +use clap::{AppSettings, Parser}; // --- darwinia-network --- use crate::chain_spec; /// 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. @@ -69,52 +69,52 @@ pub enum Subcommand { } /// 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, /// Write output in binary. Default is to write in hex. - #[structopt(long)] + #[clap(long)] pub raw: bool, /// The name of the chain for that the genesis state should be exported. - #[structopt(long)] + #[clap(long)] pub chain: Option, } /// 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, /// 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, } -#[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, - #[structopt(flatten)] + #[clap(flatten)] pub run: cumulus_client_cli::RunCmd, /// Relay chain arguments - #[structopt(raw = true)] + #[clap(raw = true)] pub relay_chain_args: Vec, } @@ -144,7 +144,7 @@ impl RelayChainCli { Self { base_path, chain_id, - base: polkadot_cli::RunCmd::from_iter(relay_chain_args), + base: polkadot_cli::RunCmd::parse_from(relay_chain_args), } } }