use clap3 instead of structopt (#10632)

* use clap3 instead of structopt

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

* format

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

* update ss58-registry and revert some nits

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

* Fix clippy and doc

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

* update clap to 3.0.7

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

* Apply review suggestions

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

* remove useless option long name

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

* cargo fmt

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
Qinxuan Chen
2022-01-25 00:28:46 +08:00
committed by GitHub
parent d1ff02d31e
commit e327b734bc
66 changed files with 660 additions and 768 deletions
+10 -15
View File
@@ -34,13 +34,13 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
# third-party dependencies
clap = { version = "3.0", features = ["derive"], optional = true }
codec = { package = "parity-scale-codec", version = "2.0.0" }
serde = { version = "1.0.132", features = ["derive"] }
futures = "0.3.16"
hex-literal = "0.3.4"
log = "0.4.8"
rand = "0.7.2"
structopt = { version = "0.3.25", optional = true }
rand = "0.8"
# primitives
sp-authority-discovery = { version = "4.0.0-dev", path = "../../../primitives/authority-discovery" }
@@ -97,12 +97,8 @@ node-inspect = { version = "0.9.0-dev", optional = true, path = "../inspect" }
try-runtime-cli = { version = "0.10.0-dev", optional = true, path = "../../../utils/frame/try-runtime/cli" }
[target.'cfg(any(target_arch="x86_64", target_arch="aarch64"))'.dependencies]
node-executor = { version = "3.0.0-dev", path = "../executor", features = [
"wasmtime",
] }
sc-cli = { version = "0.10.0-dev", optional = true, path = "../../../client/cli", features = [
"wasmtime",
] }
node-executor = { version = "3.0.0-dev", path = "../executor", features = ["wasmtime"] }
sc-cli = { version = "0.10.0-dev", optional = true, path = "../../../client/cli", features = ["wasmtime"] }
sc-service = { version = "0.10.0-dev", default-features = false, path = "../../../client/service", features = [
"wasmtime",
] }
@@ -129,7 +125,7 @@ regex = "1"
platforms = "2.0"
async-std = { version = "1.10.0", features = ["attributes"] }
soketto = "0.4.2"
criterion = { version = "0.3.5", features = [ "async_tokio" ] }
criterion = { version = "0.3.5", features = ["async_tokio"] }
tokio = { version = "1.15", features = ["macros", "time"] }
jsonrpsee-ws-client = "0.4.1"
wait-timeout = "0.2"
@@ -137,7 +133,8 @@ remote-externalities = { path = "../../../utils/frame/remote-externalities" }
pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" }
[build-dependencies]
structopt = { version = "0.3.25", optional = true }
clap = { version = "3.0", optional = true }
clap_complete = { version = "3.0", optional = true }
node-inspect = { version = "0.9.0-dev", optional = true, path = "../inspect" }
frame-benchmarking-cli = { version = "4.0.0-dev", optional = true, path = "../../../utils/frame/benchmarking-cli" }
substrate-build-script-utils = { version = "3.0.0", optional = true, path = "../../../utils/build-script-utils" }
@@ -155,14 +152,12 @@ cli = [
"frame-benchmarking-cli",
"substrate-frame-cli",
"sc-service/db",
"structopt",
"clap",
"clap_complete",
"substrate-build-script-utils",
"try-runtime-cli",
]
runtime-benchmarks = [
"node-runtime/runtime-benchmarks",
"frame-benchmarking-cli",
]
runtime-benchmarks = ["node-runtime/runtime-benchmarks", "frame-benchmarking-cli"]
# Enable features that allow the runtime to be tried and debugged. Name might be subject to change
# in the near future.
try-runtime = ["node-runtime/try-runtime", "try-runtime-cli"]
+4 -4
View File
@@ -25,7 +25,8 @@ fn main() {
mod cli {
include!("src/cli.rs");
use sc_cli::structopt::clap::Shell;
use clap::{ArgEnum, IntoApp};
use clap_complete::{generate_to, Shell};
use std::{env, fs, path::Path};
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
@@ -37,9 +38,8 @@ mod cli {
}
/// Build shell completion scripts for all known shells
/// Full list in https://github.com/kbknapp/clap-rs/blob/e9d0562a1dc5dfe731ed7c767e6cee0af08f0cf9/src/app/parser.rs#L123
fn build_shell_completion() {
for shell in &[Shell::Bash, Shell::Fish, Shell::Zsh, Shell::Elvish, Shell::PowerShell] {
for shell in Shell::value_variants() {
build_completion(shell);
}
}
@@ -61,6 +61,6 @@ mod cli {
fs::create_dir(&path).ok();
Cli::clap().gen_completions("substrate-node", *shell, &path);
let _ = generate_to(*shell, &mut Cli::into_app(), "substrate-node", &path);
}
}
+15 -16
View File
@@ -16,35 +16,30 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use sc_cli::{KeySubcommand, RunCmd, SignCmd, VanityCmd, VerifyCmd};
use structopt::StructOpt;
/// An overarching CLI command definition.
#[derive(Debug, StructOpt)]
#[derive(Debug, clap::Parser)]
pub struct Cli {
/// Possible subcommand with parameters.
#[structopt(subcommand)]
#[clap(subcommand)]
pub subcommand: Option<Subcommand>,
#[allow(missing_docs)]
#[structopt(flatten)]
pub run: RunCmd,
#[clap(flatten)]
pub run: sc_cli::RunCmd,
}
/// Possible subcommands of the main binary.
#[derive(Debug, StructOpt)]
#[derive(Debug, clap::Subcommand)]
pub enum Subcommand {
/// Key management cli utilities
Key(KeySubcommand),
/// The custom inspect subcommmand for decoding blocks and extrinsics.
#[structopt(
#[clap(
name = "inspect",
about = "Decode given block or extrinsic using current native runtime."
)]
Inspect(node_inspect::cli::InspectCmd),
/// 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.
@@ -55,14 +50,18 @@ pub enum Subcommand {
#[cfg(not(feature = "try-runtime"))]
TryRuntime,
/// Key management cli utilities
#[clap(subcommand)]
Key(sc_cli::KeySubcommand),
/// Verify a signature for a message, provided on STDIN, with a given (public or secret) key.
Verify(VerifyCmd),
Verify(sc_cli::VerifyCmd),
/// Generate a seed that provides a vanity address.
Vanity(VanityCmd),
Vanity(sc_cli::VanityCmd),
/// Sign a message, with a given (secret) key.
Sign(SignCmd),
Sign(sc_cli::SignCmd),
/// Build a chain specification.
BuildSpec(sc_cli::BuildSpecCmd),