Skip to content

Commit

Permalink
fix: use clap3 instead of structop
Browse files Browse the repository at this point in the history
  • Loading branch information
wischli committed Feb 25, 2022
1 parent a673dfe commit 17a4986
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 111 deletions.
84 changes: 9 additions & 75 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nodes/parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ runtime-common = {path = "../../runtimes/common"}
spiritnet-runtime = {path = "../../runtimes/spiritnet"}

# External dependencies
clap = { version = "3.0", features = ["derive"] }
codec = {package = "parity-scale-codec", version = "2.3.1"}
derive_more = "0.99.16"
exit-future = "0.1.4"
Expand All @@ -30,7 +31,6 @@ log = "0.4"
parking_lot = "0.9.0"
serde = {version = "1.0.124", features = ["derive"]}
serde_json = "1.0.71"
structopt = "0.3.25"
trie-root = "0.15.2"

# Substrate dependencies
Expand Down
56 changes: 28 additions & 28 deletions nodes/parachain/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
// If you feel like getting in touch with us, you can do so at info@botlabs.org

use crate::chain_spec;
use clap::{AppSettings, Parser};
use std::{ops::Deref, path::PathBuf};
use structopt::StructOpt;

pub(crate) const DEFAULT_RUNTIME: &str = "peregrine";

/// Sub-commands supported by the collator.
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub(crate) 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.
Expand All @@ -55,7 +55,7 @@ pub(crate) 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 command against runtime state.
Expand All @@ -69,13 +69,13 @@ pub(crate) enum Subcommand {
}

/// Command for building the genesis state of the parachain
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub(crate) struct BuildSpecCmd {
#[structopt(flatten)]
#[clap(flatten)]
pub(crate) inner_args: sc_cli::BuildSpecCmd,

/// The name of the runtime which should get executed.
#[structopt(long, default_value = DEFAULT_RUNTIME)]
#[clap(long, default_value = DEFAULT_RUNTIME)]
pub(crate) runtime: String,
}

Expand All @@ -88,60 +88,60 @@ impl Deref for BuildSpecCmd {
}

/// Command for exporting the genesis state of the parachain
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub(crate) struct ExportGenesisStateCommand {
/// Output file name or stdout if unspecified.
#[structopt(parse(from_os_str))]
#[clap(parse(from_os_str))]
pub(crate) output: Option<PathBuf>,

/// Write output in binary. Default is to write in hex.
#[structopt(short, long)]
#[clap(short, long)]
pub(crate) raw: bool,

/// The name of the chain for that the genesis state should be exported.
#[structopt(long)]
#[clap(long)]
pub(crate) chain: Option<String>,

/// The name of the runtime which should get executed.
#[structopt(long, default_value = DEFAULT_RUNTIME)]
#[clap(long, default_value = DEFAULT_RUNTIME)]
pub(crate) runtime: String,
}

/// Command for exporting the genesis wasm file.
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub(crate) struct ExportGenesisWasmCommand {
/// Output file name or stdout if unspecified.
#[structopt(parse(from_os_str))]
#[clap(parse(from_os_str))]
pub(crate) output: Option<PathBuf>,

/// Write output in binary. Default is to write in hex.
#[structopt(short, long)]
#[clap(short, long)]
pub(crate) raw: bool,

/// The name of the chain for that the genesis wasm file should be exported.
#[structopt(long)]
#[clap(long)]
pub(crate) 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(crate) struct Cli {
#[structopt(subcommand)]
#[clap(subcommand)]
pub(crate) subcommand: Option<Subcommand>,

#[structopt(flatten)]
#[clap(flatten)]
pub(crate) run: cumulus_client_cli::RunCmd,

/// The name of the runtime which should get executed.
#[structopt(long, default_value = DEFAULT_RUNTIME)]
#[clap(long, default_value = DEFAULT_RUNTIME)]
pub(crate) runtime: String,

/// Relaychain arguments
#[structopt(raw = true)]
#[clap(raw = true)]
pub(crate) relaychain_args: Vec<String>,
}

Expand Down Expand Up @@ -170,7 +170,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),
}
}
}
2 changes: 1 addition & 1 deletion nodes/standalone/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ mashnet-node-runtime = {path = "../../runtimes/standalone"}
runtime-common = {path = "../../runtimes/common"}

# External dependencies
clap = { version = "3.0", features = ["derive"] }
futures = "0.3"
hex-literal = "0.3.4"
log = "0.4"
serde = {version = "1.0.124", features = ["derive"]}
serde_json = "1.0.64"
structopt = "0.3.8"

# Substrate dependencies
sc-basic-authorship = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17"}
Expand Down
Loading

0 comments on commit 17a4986

Please sign in to comment.