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
@@ -24,9 +24,9 @@ use crate::{
},
params::{DatabaseParams, PruningParams},
};
use clap::Args;
use sc_client_api::execution_extensions::ExecutionStrategies;
use std::path::PathBuf;
use structopt::StructOpt;
#[cfg(feature = "wasmtime")]
const WASM_METHOD_DEFAULT: &str = "Compiled";
@@ -35,14 +35,14 @@ const WASM_METHOD_DEFAULT: &str = "Compiled";
const WASM_METHOD_DEFAULT: &str = "interpreted-i-know-what-i-do";
/// Parameters for block import.
#[derive(Debug, StructOpt, Clone)]
#[derive(Debug, Clone, Args)]
pub struct ImportParams {
#[allow(missing_docs)]
#[structopt(flatten)]
#[clap(flatten)]
pub pruning_params: PruningParams,
#[allow(missing_docs)]
#[structopt(flatten)]
#[clap(flatten)]
pub database_params: DatabaseParams,
/// Force start with unsafe pruning settings.
@@ -50,15 +50,15 @@ pub struct ImportParams {
/// When running as a validator it is highly recommended to disable state
/// pruning (i.e. 'archive') which is the default. The node will refuse to
/// start as a validator if pruning is enabled unless this option is set.
#[structopt(long = "unsafe-pruning")]
#[clap(long)]
pub unsafe_pruning: bool,
/// Method for executing Wasm runtime code.
#[structopt(
#[clap(
long = "wasm-execution",
value_name = "METHOD",
possible_values = &WasmExecutionMethod::variants(),
case_insensitive = true,
possible_values = WasmExecutionMethod::variants(),
ignore_case = true,
default_value = WASM_METHOD_DEFAULT
)]
pub wasm_method: WasmExecutionMethod,
@@ -66,15 +66,15 @@ pub struct ImportParams {
/// Specify the path where local WASM runtimes are stored.
///
/// These runtimes will override on-chain runtimes when the version matches.
#[structopt(long, value_name = "PATH", parse(from_os_str))]
#[clap(long, value_name = "PATH", parse(from_os_str))]
pub wasm_runtime_overrides: Option<PathBuf>,
#[allow(missing_docs)]
#[structopt(flatten)]
#[clap(flatten)]
pub execution_strategies: ExecutionStrategiesParams,
/// Specify the state cache size.
#[structopt(long = "state-cache-size", value_name = "Bytes", default_value = "67108864")]
#[clap(long, value_name = "Bytes", default_value = "67108864")]
pub state_cache_size: usize,
}
@@ -127,62 +127,37 @@ impl ImportParams {
}
/// Execution strategies parameters.
#[derive(Debug, StructOpt, Clone)]
#[derive(Debug, Clone, Args)]
pub struct ExecutionStrategiesParams {
/// The means of execution used when calling into the runtime for importing blocks as
/// part of an initial sync.
#[structopt(
long = "execution-syncing",
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
)]
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)]
pub execution_syncing: Option<ExecutionStrategy>,
/// The means of execution used when calling into the runtime for general block import
/// (including locally authored blocks).
#[structopt(
long = "execution-import-block",
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
)]
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)]
pub execution_import_block: Option<ExecutionStrategy>,
/// The means of execution used when calling into the runtime while constructing blocks.
#[structopt(
long = "execution-block-construction",
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
)]
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)]
pub execution_block_construction: Option<ExecutionStrategy>,
/// The means of execution used when calling into the runtime while using an off-chain worker.
#[structopt(
long = "execution-offchain-worker",
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
)]
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)]
pub execution_offchain_worker: Option<ExecutionStrategy>,
/// The means of execution used when calling into the runtime while not syncing, importing or
/// constructing blocks.
#[structopt(
long = "execution-other",
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
)]
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)]
pub execution_other: Option<ExecutionStrategy>,
/// The execution strategy that should be used by all execution contexts.
#[structopt(
long = "execution",
#[clap(
long,
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
arg_enum,
ignore_case = true,
conflicts_with_all = &[
"execution-other",
"execution-offchain-worker",