Normalization of CLI options format (CamelCase => kebab-case) (#11194)

* Convert cli options from 'CamelCase' to 'kebab-case'
* Remove not required 'as_str' for 'ExecutionStrategy' option
This commit is contained in:
Davide Galassi
2022-04-11 09:45:45 +02:00
committed by GitHub
parent 9090f0d2a2
commit 641a43a05d
8 changed files with 32 additions and 38 deletions
+9 -21
View File
@@ -88,7 +88,7 @@ impl Into<sc_service::config::WasmExecutionMethod> for WasmExecutionMethod {
/// The default [`WasmExecutionMethod`]. /// The default [`WasmExecutionMethod`].
#[cfg(feature = "wasmtime")] #[cfg(feature = "wasmtime")]
pub const DEFAULT_WASM_EXECUTION_METHOD: &str = "Compiled"; pub const DEFAULT_WASM_EXECUTION_METHOD: &str = "compiled";
/// The default [`WasmExecutionMethod`]. /// The default [`WasmExecutionMethod`].
#[cfg(not(feature = "wasmtime"))] #[cfg(not(feature = "wasmtime"))]
@@ -96,7 +96,7 @@ pub const DEFAULT_WASM_EXECUTION_METHOD: &str = "interpreted-i-know-what-i-do";
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)] #[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)]
#[clap(rename_all = "PascalCase")] #[clap(rename_all = "kebab-case")]
pub enum TracingReceiver { pub enum TracingReceiver {
/// Output the tracing records using the log. /// Output the tracing records using the log.
Log, Log,
@@ -112,7 +112,7 @@ impl Into<sc_tracing::TracingReceiver> for TracingReceiver {
/// The type of the node key. /// The type of the node key.
#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)] #[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)]
#[clap(rename_all = "PascalCase")] #[clap(rename_all = "kebab-case")]
pub enum NodeKeyType { pub enum NodeKeyType {
/// Use ed25519. /// Use ed25519.
Ed25519, Ed25519,
@@ -120,7 +120,7 @@ pub enum NodeKeyType {
/// The crypto scheme to use. /// The crypto scheme to use.
#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)] #[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)]
#[clap(rename_all = "PascalCase")] #[clap(rename_all = "kebab-case")]
pub enum CryptoScheme { pub enum CryptoScheme {
/// Use ed25519. /// Use ed25519.
Ed25519, Ed25519,
@@ -132,7 +132,7 @@ pub enum CryptoScheme {
/// The type of the output format. /// The type of the output format.
#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)] #[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)]
#[clap(rename_all = "PascalCase")] #[clap(rename_all = "kebab-case")]
pub enum OutputType { pub enum OutputType {
/// Output as json. /// Output as json.
Json, Json,
@@ -142,7 +142,7 @@ pub enum OutputType {
/// How to execute blocks /// How to execute blocks
#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)] #[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)]
#[clap(rename_all = "PascalCase")] #[clap(rename_all = "kebab-case")]
pub enum ExecutionStrategy { pub enum ExecutionStrategy {
/// Execute with native build (if available, WebAssembly otherwise). /// Execute with native build (if available, WebAssembly otherwise).
Native, Native,
@@ -165,22 +165,10 @@ impl Into<sc_client_api::ExecutionStrategy> for ExecutionStrategy {
} }
} }
impl ExecutionStrategy {
/// Returns the variant as `'&static str`.
pub fn as_str(&self) -> &'static str {
match self {
Self::Native => "Native",
Self::Wasm => "Wasm",
Self::Both => "Both",
Self::NativeElseWasm => "NativeElseWasm",
}
}
}
/// Available RPC methods. /// Available RPC methods.
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, Copy, Clone, PartialEq, ArgEnum)] #[derive(Debug, Copy, Clone, PartialEq, ArgEnum)]
#[clap(rename_all = "PascalCase")] #[clap(rename_all = "kebab-case")]
pub enum RpcMethods { pub enum RpcMethods {
/// Expose every RPC method only when RPC is listening on `localhost`, /// Expose every RPC method only when RPC is listening on `localhost`,
/// otherwise serve only safe RPC methods. /// otherwise serve only safe RPC methods.
@@ -243,7 +231,7 @@ impl Database {
/// Whether off-chain workers are enabled. /// Whether off-chain workers are enabled.
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, Clone, ArgEnum)] #[derive(Debug, Clone, ArgEnum)]
#[clap(rename_all = "PascalCase")] #[clap(rename_all = "kebab-case")]
pub enum OffchainWorkerEnabled { pub enum OffchainWorkerEnabled {
/// Always have offchain worker enabled. /// Always have offchain worker enabled.
Always, Always,
@@ -255,7 +243,7 @@ pub enum OffchainWorkerEnabled {
/// Syncing mode. /// Syncing mode.
#[derive(Debug, Clone, Copy, ArgEnum, PartialEq)] #[derive(Debug, Clone, Copy, ArgEnum, PartialEq)]
#[clap(rename_all = "PascalCase")] #[clap(rename_all = "kebab-case")]
pub enum SyncMode { pub enum SyncMode {
/// Full sync. Download end verify all blocks. /// Full sync. Download end verify all blocks.
Full, Full,
+5 -5
View File
@@ -71,16 +71,16 @@ pub struct RunCmd {
/// RPC methods to expose. /// RPC methods to expose.
/// ///
/// - `Unsafe`: Exposes every RPC method. /// - `unsafe`: Exposes every RPC method.
/// - `Safe`: Exposes only a safe subset of RPC methods, denying unsafe RPC methods. /// - `safe`: Exposes only a safe subset of RPC methods, denying unsafe RPC methods.
/// - `Auto`: Acts as `Safe` if RPC is served externally, e.g. when `--{rpc,ws}-external` is /// - `auto`: Acts as `safe` if RPC is served externally, e.g. when `--{rpc,ws}-external` is
/// passed, otherwise acts as `Unsafe`. /// passed, otherwise acts as `unsafe`.
#[clap( #[clap(
long, long,
value_name = "METHOD SET", value_name = "METHOD SET",
arg_enum, arg_enum,
ignore_case = true, ignore_case = true,
default_value = "Auto", default_value = "auto",
verbatim_doc_comment verbatim_doc_comment
)] )]
pub rpc_methods: RpcMethods, pub rpc_methods: RpcMethods,
+2 -2
View File
@@ -118,7 +118,7 @@ impl BlockNumberOrHash {
#[derive(Debug, Clone, Args)] #[derive(Debug, Clone, Args)]
pub struct CryptoSchemeFlag { pub struct CryptoSchemeFlag {
/// cryptography scheme /// cryptography scheme
#[clap(long, value_name = "SCHEME", arg_enum, ignore_case = true, default_value = "Sr25519")] #[clap(long, value_name = "SCHEME", arg_enum, ignore_case = true, default_value = "sr25519")]
pub scheme: CryptoScheme, pub scheme: CryptoScheme,
} }
@@ -126,7 +126,7 @@ pub struct CryptoSchemeFlag {
#[derive(Debug, Clone, Args)] #[derive(Debug, Clone, Args)]
pub struct OutputTypeFlag { pub struct OutputTypeFlag {
/// output format /// output format
#[clap(long, value_name = "FORMAT", arg_enum, ignore_case = true, default_value = "Text")] #[clap(long, value_name = "FORMAT", arg_enum, ignore_case = true, default_value = "text")]
pub output_type: OutputType, pub output_type: OutputType,
} }
@@ -132,12 +132,18 @@ pub struct NetworkParams {
/// Blockchain syncing mode. /// Blockchain syncing mode.
/// ///
/// - `Full`: Download and validate full blockchain history. /// - `full`: Download and validate full blockchain history.
/// /// - `fast`: Download blocks and the latest state only.
/// - `Fast`: Download blocks and the latest state only. /// - `fast-unsafe`: Same as `fast`, but skip downloading state proofs.
/// /// - `warp`: Download the latest state and proof.
/// - `FastUnsafe`: Same as `Fast`, but skip downloading state proofs. #[clap(
#[clap(long, arg_enum, value_name = "SYNC_MODE", default_value = "Full", ignore_case(true))] long,
arg_enum,
value_name = "SYNC_MODE",
default_value = "full",
ignore_case = true,
verbatim_doc_comment
)]
pub sync: SyncMode, pub sync: SyncMode,
} }
@@ -66,7 +66,7 @@ pub struct NodeKeyParams {
/// ///
/// The node's secret key determines the corresponding public key and hence the /// The node's secret key determines the corresponding public key and hence the
/// node's peer ID in the context of libp2p. /// node's peer ID in the context of libp2p.
#[clap(long, value_name = "TYPE", arg_enum, ignore_case = true, default_value = "Ed25519")] #[clap(long, value_name = "TYPE", arg_enum, ignore_case = true, default_value = "ed25519")]
pub node_key_type: NodeKeyType, pub node_key_type: NodeKeyType,
/// The file from which to read the node's secret key to use for libp2p networking. /// The file from which to read the node's secret key to use for libp2p networking.
@@ -40,7 +40,7 @@ pub struct OffchainWorkerParams {
value_name = "ENABLED", value_name = "ENABLED",
arg_enum, arg_enum,
ignore_case = true, ignore_case = true,
default_value = "WhenValidating" default_value = "when-validating"
)] )]
pub enabled: OffchainWorkerEnabled, pub enabled: OffchainWorkerEnabled,
@@ -76,7 +76,7 @@ pub struct SharedParams {
pub tracing_targets: Option<String>, pub tracing_targets: Option<String>,
/// Receiver to process tracing messages. /// Receiver to process tracing messages.
#[clap(long, value_name = "RECEIVER", arg_enum, ignore_case = true, default_value = "Log")] #[clap(long, value_name = "RECEIVER", arg_enum, ignore_case = true, default_value = "log")]
pub tracing_receiver: TracingReceiver, pub tracing_receiver: TracingReceiver,
} }
@@ -387,7 +387,7 @@ pub struct SharedParams {
pub shared_params: sc_cli::SharedParams, pub shared_params: sc_cli::SharedParams,
/// The execution strategy that should be used. /// The execution strategy that should be used.
#[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true, default_value = "Wasm")] #[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true, default_value = "wasm")]
pub execution: ExecutionStrategy, pub execution: ExecutionStrategy,
/// Type of wasm execution used. /// Type of wasm execution used.