From 5c05eed5e38f0856e9cb75d76a0b51dbb2983302 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Fri, 23 Sep 2022 12:55:19 +0200 Subject: [PATCH 01/20] Bump clap to 3.2.22 --- Cargo.lock | 50 +++++++++---------- bin/node-template/node/Cargo.toml | 2 +- bin/node/bench/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 4 +- bin/utils/chain-spec-builder/Cargo.toml | 2 +- bin/utils/subkey/Cargo.toml | 2 +- client/cli/Cargo.toml | 2 +- .../solution-type/fuzzer/Cargo.toml | 2 +- primitives/npos-elections/fuzzer/Cargo.toml | 4 +- utils/frame/benchmarking-cli/Cargo.toml | 2 +- utils/frame/frame-utilities-cli/Cargo.toml | 2 +- .../generate-bags/node-runtime/Cargo.toml | 2 +- utils/frame/try-runtime/cli/Cargo.toml | 2 +- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d1349ce488fa7..b0bd406f7eaf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -919,7 +919,7 @@ name = "chain-spec-builder" version = "2.0.0" dependencies = [ "ansi_term", - "clap 3.1.18", + "clap 3.2.22", "node-cli", "rand 0.8.5", "sc-chain-spec", @@ -996,19 +996,19 @@ dependencies = [ [[package]] name = "clap" -version = "3.1.18" +version = "3.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" +checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" dependencies = [ "atty", "bitflags", "clap_derive", "clap_lex", "indexmap", - "lazy_static", + "once_cell", "strsim", "termcolor", - "textwrap 0.15.0", + "textwrap 0.15.1", ] [[package]] @@ -1017,14 +1017,14 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a394f7ec0715b42a4e52b294984c27c9a61f77c8d82f7774c5198350be143f19" dependencies = [ - "clap 3.1.18", + "clap 3.2.22", ] [[package]] name = "clap_derive" -version = "3.1.18" +version = "3.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c" +checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" dependencies = [ "heck", "proc-macro-error", @@ -1035,9 +1035,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.0" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" dependencies = [ "os_str_bytes", ] @@ -2146,7 +2146,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 3.1.18", + "clap 3.2.22", "comfy-table", "frame-benchmarking", "frame-support", @@ -2227,7 +2227,7 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 3.1.18", + "clap 3.2.22", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", @@ -4638,7 +4638,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes", - "clap 3.1.18", + "clap 3.2.22", "derive_more", "fs_extra", "futures", @@ -4677,7 +4677,7 @@ dependencies = [ "array-bytes", "assert_cmd", "async-std", - "clap 3.1.18", + "clap 3.2.22", "clap_complete", "criterion", "frame-benchmarking-cli", @@ -4794,7 +4794,7 @@ dependencies = [ name = "node-inspect" version = "0.9.0-dev" dependencies = [ - "clap 3.1.18", + "clap 3.2.22", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -4854,7 +4854,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 3.1.18", + "clap 3.2.22", "generate-bags", "kitchensink-runtime", ] @@ -4863,7 +4863,7 @@ dependencies = [ name = "node-template" version = "4.0.0-dev" dependencies = [ - "clap 3.1.18", + "clap 3.2.22", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -7921,7 +7921,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "chrono", - "clap 3.1.18", + "clap 3.2.22", "fdlimit", "futures", "libp2p", @@ -10003,7 +10003,7 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 3.1.18", + "clap 3.2.22", "honggfuzz", "parity-scale-codec", "rand 0.8.5", @@ -10500,7 +10500,7 @@ dependencies = [ name = "subkey" version = "2.0.2" dependencies = [ - "clap 3.1.18", + "clap 3.2.22", "sc-cli", ] @@ -10528,7 +10528,7 @@ dependencies = [ name = "substrate-frame-cli" version = "4.0.0-dev" dependencies = [ - "clap 3.1.18", + "clap 3.2.22", "frame-support", "frame-system", "sc-cli", @@ -10860,9 +10860,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" +checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" [[package]] name = "thiserror" @@ -11274,7 +11274,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" name = "try-runtime-cli" version = "0.10.0-dev" dependencies = [ - "clap 3.1.18", + "clap 3.2.22", "frame-try-runtime", "jsonrpsee", "log", @@ -11324,7 +11324,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "digest 0.10.3", "rand 0.8.5", "static_assertions", diff --git a/bin/node-template/node/Cargo.toml b/bin/node-template/node/Cargo.toml index dc1d3caa8b75d..47b058815672c 100644 --- a/bin/node-template/node/Cargo.toml +++ b/bin/node-template/node/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] name = "node-template" [dependencies] -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } sc-cli = { version = "0.10.0-dev", path = "../../../client/cli", features = ["wasmtime"] } sp-core = { version = "6.0.0", path = "../../../primitives/core" } diff --git a/bin/node/bench/Cargo.toml b/bin/node/bench/Cargo.toml index a9c367ae8aa3d..64681ee213650 100644 --- a/bin/node/bench/Cargo.toml +++ b/bin/node/bench/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/" [dependencies] array-bytes = "4.1" -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } log = "0.4.17" node-primitives = { version = "2.0.0", path = "../primitives" } node-testing = { version = "3.0.0-dev", path = "../testing" } diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index edb434e3c04e3..5f5b05b707c1a 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -35,7 +35,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] # third-party dependencies array-bytes = "4.1" -clap = { version = "3.1.18", features = ["derive"], optional = true } +clap = { version = "3.2.22", features = ["derive", "deprecated"], optional = true } codec = { package = "parity-scale-codec", version = "3.0.0" } serde = { version = "1.0.136", features = ["derive"] } jsonrpsee = { version = "0.15.1", features = ["server"] } @@ -136,7 +136,7 @@ remote-externalities = { path = "../../../utils/frame/remote-externalities" } pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" } [build-dependencies] -clap = { version = "3.1.18", optional = true } +clap = { version = "3.2.22", 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" } diff --git a/bin/utils/chain-spec-builder/Cargo.toml b/bin/utils/chain-spec-builder/Cargo.toml index e3deb54ea8ac9..ae13a2052afa9 100644 --- a/bin/utils/chain-spec-builder/Cargo.toml +++ b/bin/utils/chain-spec-builder/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] ansi_term = "0.12.1" -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } rand = "0.8" node-cli = { version = "3.0.0-dev", path = "../../node/cli" } sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" } diff --git a/bin/utils/subkey/Cargo.toml b/bin/utils/subkey/Cargo.toml index 4c4e47e702be6..68e60be903c45 100644 --- a/bin/utils/subkey/Cargo.toml +++ b/bin/utils/subkey/Cargo.toml @@ -17,5 +17,5 @@ path = "src/main.rs" name = "subkey" [dependencies] -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" } diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index e5cd6167596c0..a549111b5650f 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" chrono = "0.4.10" -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } fdlimit = "0.2.1" futures = "0.3.21" libp2p = "0.46.1" diff --git a/frame/election-provider-support/solution-type/fuzzer/Cargo.toml b/frame/election-provider-support/solution-type/fuzzer/Cargo.toml index 10f82cd316851..8e04e8c232d4a 100644 --- a/frame/election-provider-support/solution-type/fuzzer/Cargo.toml +++ b/frame/election-provider-support/solution-type/fuzzer/Cargo.toml @@ -13,7 +13,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } honggfuzz = "0.5" rand = { version = "0.8", features = ["std", "small_rng"] } diff --git a/primitives/npos-elections/fuzzer/Cargo.toml b/primitives/npos-elections/fuzzer/Cargo.toml index a200d5c41ee35..271e77450f5f2 100644 --- a/primitives/npos-elections/fuzzer/Cargo.toml +++ b/primitives/npos-elections/fuzzer/Cargo.toml @@ -14,7 +14,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } honggfuzz = "0.5" rand = { version = "0.8", features = ["std", "small_rng"] } @@ -36,4 +36,4 @@ path = "src/phragmms_balancing.rs" [[bin]] name = "phragmen_pjr" -path = "src/phragmen_pjr.rs" \ No newline at end of file +path = "src/phragmen_pjr.rs" diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index 108d0d338c2b3..1af6dc878cb11 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" chrono = "0.4" -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } codec = { package = "parity-scale-codec", version = "3.0.0" } comfy-table = { version = "6.0.0", default-features = false } handlebars = "4.2.2" diff --git a/utils/frame/frame-utilities-cli/Cargo.toml b/utils/frame/frame-utilities-cli/Cargo.toml index f01e2f1a5d51f..91cb5fc24efde 100644 --- a/utils/frame/frame-utilities-cli/Cargo.toml +++ b/utils/frame/frame-utilities-cli/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/substrate-frame-cli" readme = "README.md" [dependencies] -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } frame-support = { version = "4.0.0-dev", path = "../../../frame/support" } frame-system = { version = "4.0.0-dev", path = "../../../frame/system" } sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" } diff --git a/utils/frame/generate-bags/node-runtime/Cargo.toml b/utils/frame/generate-bags/node-runtime/Cargo.toml index 5af7dd78a08e8..96af7d31ed67e 100644 --- a/utils/frame/generate-bags/node-runtime/Cargo.toml +++ b/utils/frame/generate-bags/node-runtime/Cargo.toml @@ -14,4 +14,4 @@ kitchensink-runtime = { version = "3.0.0-dev", path = "../../../../bin/node/runt generate-bags = { version = "4.0.0-dev", path = "../" } # third-party -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } diff --git a/utils/frame/try-runtime/cli/Cargo.toml b/utils/frame/try-runtime/cli/Cargo.toml index 56ead30644d86..f54f14844d3ba 100644 --- a/utils/frame/try-runtime/cli/Cargo.toml +++ b/utils/frame/try-runtime/cli/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "3.2.22", features = ["derive", "deprecated"] } log = "0.4.17" parity-scale-codec = "3.0.0" serde = "1.0.136" From 722c34495acadf3a840e6b1ae105cd88d8a6adcc Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Fri, 23 Sep 2022 12:55:54 +0200 Subject: [PATCH 02/20] Replace `from_os_str` with `value_parser` --- client/cli/src/commands/export_blocks_cmd.rs | 2 +- client/cli/src/commands/import_blocks_cmd.rs | 2 +- client/cli/src/params/import_params.rs | 2 +- client/cli/src/params/keystore_params.rs | 4 ++-- client/cli/src/params/shared_params.rs | 2 +- scripts/ci/node-template-release/src/main.rs | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/cli/src/commands/export_blocks_cmd.rs b/client/cli/src/commands/export_blocks_cmd.rs index ff35b5a51fcad..ba64757da3740 100644 --- a/client/cli/src/commands/export_blocks_cmd.rs +++ b/client/cli/src/commands/export_blocks_cmd.rs @@ -32,7 +32,7 @@ use std::{fmt::Debug, fs, io, path::PathBuf, str::FromStr, sync::Arc}; #[derive(Debug, Clone, Parser)] pub struct ExportBlocksCmd { /// Output file name or stdout if unspecified. - #[clap(parse(from_os_str))] + #[clap(value_parser)] pub output: Option, /// Specify starting block number. diff --git a/client/cli/src/commands/import_blocks_cmd.rs b/client/cli/src/commands/import_blocks_cmd.rs index 749824834bf7b..b56bede49e0c6 100644 --- a/client/cli/src/commands/import_blocks_cmd.rs +++ b/client/cli/src/commands/import_blocks_cmd.rs @@ -37,7 +37,7 @@ use std::{ #[derive(Debug, Parser)] pub struct ImportBlocksCmd { /// Input file or stdin if unspecified. - #[clap(parse(from_os_str))] + #[clap(value_parser)] pub input: Option, /// The default number of 64KB pages to ever allocate for Wasm execution. diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs index c851050838965..9b7e264ea3e2d 100644 --- a/client/cli/src/params/import_params.rs +++ b/client/cli/src/params/import_params.rs @@ -87,7 +87,7 @@ pub struct ImportParams { /// Specify the path where local WASM runtimes are stored. /// /// These runtimes will override on-chain runtimes when the version matches. - #[clap(long, value_name = "PATH", parse(from_os_str))] + #[clap(long, value_name = "PATH", value_parser)] pub wasm_runtime_overrides: Option, #[allow(missing_docs)] diff --git a/client/cli/src/params/keystore_params.rs b/client/cli/src/params/keystore_params.rs index 386d1791dd805..673afa51d6b41 100644 --- a/client/cli/src/params/keystore_params.rs +++ b/client/cli/src/params/keystore_params.rs @@ -36,7 +36,7 @@ pub struct KeystoreParams { pub keystore_uri: Option, /// Specify custom keystore path. - #[clap(long, value_name = "PATH", parse(from_os_str))] + #[clap(long, value_name = "PATH", value_parser)] pub keystore_path: Option, /// Use interactive shell for entering the password used by the keystore. @@ -56,7 +56,7 @@ pub struct KeystoreParams { #[clap( long, value_name = "PATH", - parse(from_os_str), + value_parser, conflicts_with_all = &["password-interactive", "password"] )] pub password_filename: Option, diff --git a/client/cli/src/params/shared_params.rs b/client/cli/src/params/shared_params.rs index 4a8fc4bcfffdd..3f8ed6b5940e6 100644 --- a/client/cli/src/params/shared_params.rs +++ b/client/cli/src/params/shared_params.rs @@ -39,7 +39,7 @@ pub struct SharedParams { pub dev: bool, /// Specify custom base path. - #[clap(long, short = 'd', value_name = "PATH", parse(from_os_str))] + #[clap(long, short = 'd', value_name = "PATH", value_parser)] pub base_path: Option, /// Sets a custom logging filter. Syntax is =, e.g. -lsync=debug. diff --git a/scripts/ci/node-template-release/src/main.rs b/scripts/ci/node-template-release/src/main.rs index 62e9b66715768..6c47f3cdcc701 100644 --- a/scripts/ci/node-template-release/src/main.rs +++ b/scripts/ci/node-template-release/src/main.rs @@ -29,10 +29,10 @@ type CargoToml = HashMap; #[derive(Parser)] struct Options { /// The path to the `node-template` source. - #[clap(parse(from_os_str))] + #[clap(value_parser)] node_template: PathBuf, /// The path where to output the generated `tar.gz` file. - #[clap(parse(from_os_str))] + #[clap(value_parser)] output: PathBuf, } From 4c9000ac976b03647e3961dfd9c1f992eccfdb12 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Fri, 23 Sep 2022 13:32:19 +0200 Subject: [PATCH 03/20] Replace `from_str` and `try_from_str` with `value_parser` --- client/cli/src/commands/run_cmd.rs | 10 +++++----- client/cli/src/commands/vanity.rs | 2 +- client/cli/src/params/keystore_params.rs | 2 +- utils/frame/benchmarking-cli/src/pallet/mod.rs | 6 +++--- .../try-runtime/cli/src/commands/execute_block.rs | 4 ++-- .../frame/try-runtime/cli/src/commands/follow_chain.rs | 2 +- .../try-runtime/cli/src/commands/offchain_worker.rs | 4 ++-- utils/frame/try-runtime/cli/src/lib.rs | 6 +++--- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/client/cli/src/commands/run_cmd.rs b/client/cli/src/commands/run_cmd.rs index 11cfb9d0ff651..7cdeea03f2811 100644 --- a/client/cli/src/commands/run_cmd.rs +++ b/client/cli/src/commands/run_cmd.rs @@ -148,7 +148,7 @@ pub struct RunCmd { /// value). Value of `all` will disable origin validation. Default is to /// allow localhost and origins. When running in /// --dev mode the default is to allow all origins. - #[clap(long, value_name = "ORIGINS", parse(from_str = parse_cors))] + #[clap(long, value_name = "ORIGINS", value_parser = parse_cors)] pub rpc_cors: Option, /// Specify Prometheus exporter TCP Port. @@ -179,7 +179,7 @@ pub struct RunCmd { /// telemetry endpoints. Verbosity levels range from 0-9, with 0 denoting /// the least verbosity. /// Expected format is 'URL VERBOSITY', e.g. `--telemetry-url 'wss://foo/bar 0'`. - #[clap(long = "telemetry-url", value_name = "URL VERBOSITY", parse(try_from_str = parse_telemetry_endpoints))] + #[clap(long = "telemetry-url", value_name = "URL VERBOSITY", value_parser = parse_telemetry_endpoints)] pub telemetry_endpoints: Vec<(String, u8)>, #[allow(missing_docs)] @@ -597,7 +597,7 @@ impl From for Option> { } /// Parse cors origins. -fn parse_cors(s: &str) -> Cors { +fn parse_cors(s: &str) -> std::result::Result { let mut is_all = false; let mut origins = Vec::new(); for part in s.split(',') { @@ -611,9 +611,9 @@ fn parse_cors(s: &str) -> Cors { } if is_all { - Cors::All + Ok(Cors::All) } else { - Cors::List(origins) + Ok(Cors::List(origins)) } } diff --git a/client/cli/src/commands/vanity.rs b/client/cli/src/commands/vanity.rs index 289dc1705c3a3..f61760c0308e9 100644 --- a/client/cli/src/commands/vanity.rs +++ b/client/cli/src/commands/vanity.rs @@ -32,7 +32,7 @@ use utils::print_from_uri; #[clap(name = "vanity", about = "Generate a seed that provides a vanity address")] pub struct VanityCmd { /// Desired pattern - #[clap(long, parse(try_from_str = assert_non_empty_string))] + #[clap(long, value_parser = assert_non_empty_string)] pattern: String, #[allow(missing_docs)] diff --git a/client/cli/src/params/keystore_params.rs b/client/cli/src/params/keystore_params.rs index 673afa51d6b41..a298a9abaca8f 100644 --- a/client/cli/src/params/keystore_params.rs +++ b/client/cli/src/params/keystore_params.rs @@ -47,7 +47,7 @@ pub struct KeystoreParams { /// seed. #[clap( long, - parse(try_from_str = secret_string_from_str), + value_parser = secret_string_from_str, conflicts_with_all = &["password-interactive", "password-filename"] )] pub password: Option, diff --git a/utils/frame/benchmarking-cli/src/pallet/mod.rs b/utils/frame/benchmarking-cli/src/pallet/mod.rs index b8c1f7b905c0c..4bf9c5198ef72 100644 --- a/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -27,15 +27,15 @@ use std::{fmt::Debug, path::PathBuf}; // Add a more relaxed parsing for pallet names by allowing pallet directory names with `-` to be // used like crate names with `_` -fn parse_pallet_name(pallet: &str) -> String { - pallet.replace("-", "_") +fn parse_pallet_name(pallet: &str) -> std::result::Result { + Ok(pallet.replace("-", "_")) } /// Benchmark the extrinsic weight of FRAME Pallets. #[derive(Debug, clap::Parser)] pub struct PalletCmd { /// Select a FRAME Pallet to benchmark, or `*` for all (in which case `extrinsic` must be `*`). - #[clap(short, long, parse(from_str = parse_pallet_name), required_unless_present = "list")] + #[clap(short, long, value_parser = parse_pallet_name, required_unless_present = "list")] pub pallet: Option, /// Select an extrinsic inside the pallet to benchmark, or `*` for all. diff --git a/utils/frame/try-runtime/cli/src/commands/execute_block.rs b/utils/frame/try-runtime/cli/src/commands/execute_block.rs index 0c8b968d1b4b1..bc5ea1db140fe 100644 --- a/utils/frame/try-runtime/cli/src/commands/execute_block.rs +++ b/utils/frame/try-runtime/cli/src/commands/execute_block.rs @@ -59,7 +59,7 @@ pub struct ExecuteBlockCmd { #[clap( long, multiple_values = false, - parse(try_from_str = crate::parse::hash) + value_parser = crate::parse::hash )] block_at: Option, @@ -70,7 +70,7 @@ pub struct ExecuteBlockCmd { #[clap( long, multiple_values = false, - parse(try_from_str = crate::parse::url) + value_parser = crate::parse::url )] block_ws_uri: Option, diff --git a/utils/frame/try-runtime/cli/src/commands/follow_chain.rs b/utils/frame/try-runtime/cli/src/commands/follow_chain.rs index 88866b538169b..96ad635abe63c 100644 --- a/utils/frame/try-runtime/cli/src/commands/follow_chain.rs +++ b/utils/frame/try-runtime/cli/src/commands/follow_chain.rs @@ -42,7 +42,7 @@ const UN_SUB: &str = "chain_unsubscribeFinalizedHeads"; #[derive(Debug, Clone, clap::Parser)] pub struct FollowChainCmd { /// The url to connect to. - #[clap(short, long, parse(try_from_str = parse::url))] + #[clap(short, long, value_parser = parse::url)] uri: String, /// If set, then the state root check is enabled. diff --git a/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs b/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs index b0404fff18135..b660d0dfad969 100644 --- a/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs +++ b/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs @@ -41,7 +41,7 @@ pub struct OffchainWorkerCmd { #[clap( long, multiple_values = false, - parse(try_from_str = parse::hash) + value_parser = parse::hash )] header_at: Option, @@ -52,7 +52,7 @@ pub struct OffchainWorkerCmd { #[clap( long, multiple_values = false, - parse(try_from_str = parse::url) + value_parser = parse::url )] header_ws_uri: Option, diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index b8a2779d57e19..0ef610a64463a 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -426,7 +426,7 @@ pub struct SharedParams { pub no_spec_check_panic: bool, /// State version that is used by the chain. - #[clap(long, default_value = "1", parse(try_from_str = parse::state_version))] + #[clap(long, default_value = "1", value_parser = parse::state_version)] pub state_version: StateVersion, } @@ -459,7 +459,7 @@ pub enum State { #[clap( short, long, - parse(try_from_str = parse::url), + value_parser = parse::url, )] uri: String, @@ -471,7 +471,7 @@ pub enum State { short, long, multiple_values = false, - parse(try_from_str = parse::hash), + value_parser = parse::hash, )] at: Option, From a2074da6b03f63f9eab7676844825bc7aef7740a Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Tue, 27 Sep 2022 19:40:47 +0200 Subject: [PATCH 04/20] Move possible_values to the new format --- client/cli/src/arg_enums.rs | 77 +++++++++---------- client/cli/src/params/database_params.rs | 8 +- client/cli/src/params/import_params.rs | 2 +- client/cli/src/params/mod.rs | 19 ++++- .../frame/benchmarking-cli/src/pallet/mod.rs | 2 +- .../frame/benchmarking-cli/src/storage/cmd.rs | 2 +- .../frame-utilities-cli/src/pallet_id.rs | 3 +- utils/frame/try-runtime/cli/src/lib.rs | 2 +- 8 files changed, 57 insertions(+), 58 deletions(-) diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index 283fef985dfb9..4d664b3ffcc4f 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -18,7 +18,7 @@ //! Definitions of [`ArgEnum`] types. -use clap::ArgEnum; +use clap::{ArgEnum, PossibleValue}; /// The instantiation strategy to use in compiled mode. #[derive(Debug, Clone, Copy, ArgEnum)] @@ -59,20 +59,22 @@ pub enum WasmExecutionMethod { Compiled, } -impl std::fmt::Display for WasmExecutionMethod { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Interpreted => write!(f, "Interpreted"), - Self::Compiled => write!(f, "Compiled"), +const INTERPRETED_NAME: &str = "interpreted-i-know-what-i-do"; + +impl clap::ValueEnum for WasmExecutionMethod { + /// All possible argument values, in display order. + fn value_variants<'a>() -> &'a [Self] { + let variants = &[Self::Interpreted, Self::Compiled]; + if cfg!(feature = "wasmtime") { + variants + } else { + &variants[..1] } } -} -impl std::str::FromStr for WasmExecutionMethod { - type Err = String; - - fn from_str(s: &str) -> Result { - if s.eq_ignore_ascii_case("interpreted-i-know-what-i-do") { + /// Parse an argument into `Self`. + fn from_str(s: &str, _: bool) -> Result { + if s.eq_ignore_ascii_case(INTERPRETED_NAME) { Ok(Self::Interpreted) } else if s.eq_ignore_ascii_case("compiled") { #[cfg(feature = "wasmtime")] @@ -84,19 +86,27 @@ impl std::str::FromStr for WasmExecutionMethod { Err("`Compiled` variant requires the `wasmtime` feature to be enabled".into()) } } else { - Err(format!("Unknown variant `{}`, known variants: {:?}", s, Self::variants())) + Err(format!("Unknown variant `{}`", s)) } } + + /// The canonical argument value. + /// + /// The value is `None` for skipped variants. + fn to_possible_value<'a>(&self) -> Option> { + Some(match self { + #[cfg(feature = "wasmtime")] + WasmExecutionMethod::Compiled => PossibleValue::new("compiled"), + WasmExecutionMethod::Interpreted => PossibleValue::new(INTERPRETED_NAME), + }) + } } -impl WasmExecutionMethod { - /// Returns all the variants of this enum to be shown in the cli. - pub fn variants() -> &'static [&'static str] { - let variants = &["interpreted-i-know-what-i-do", "compiled"]; - if cfg!(feature = "wasmtime") { - variants - } else { - &variants[..1] +impl std::fmt::Display for WasmExecutionMethod { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Interpreted => write!(f, "Interpreted"), + Self::Compiled => write!(f, "Compiled"), } } } @@ -107,6 +117,7 @@ pub fn execution_method_from_cli( execution_method: WasmExecutionMethod, _instantiation_strategy: WasmtimeInstantiationStrategy, ) -> sc_service::config::WasmExecutionMethod { + println!("execution method: {:?}", execution_method); match execution_method { WasmExecutionMethod::Interpreted => sc_service::config::WasmExecutionMethod::Interpreted, #[cfg(feature = "wasmtime")] @@ -235,7 +246,8 @@ impl Into for RpcMethods { } /// Database backend -#[derive(Debug, Clone, PartialEq, Copy)] +#[derive(Debug, Clone, PartialEq, Copy, clap::ValueEnum)] +#[clap(rename_all = "lower")] pub enum Database { /// Facebooks RocksDB #[cfg(feature = "rocksdb")] @@ -246,29 +258,10 @@ pub enum Database { /// instance of ParityDb Auto, /// ParityDb. + #[clap(alias = "paritydb-experimental")] ParityDbDeprecated, } -impl std::str::FromStr for Database { - type Err = String; - - fn from_str(s: &str) -> Result { - #[cfg(feature = "rocksdb")] - if s.eq_ignore_ascii_case("rocksdb") { - return Ok(Self::RocksDb) - } - if s.eq_ignore_ascii_case("paritydb-experimental") { - return Ok(Self::ParityDbDeprecated) - } else if s.eq_ignore_ascii_case("paritydb") { - return Ok(Self::ParityDb) - } else if s.eq_ignore_ascii_case("auto") { - Ok(Self::Auto) - } else { - Err(format!("Unknown variant `{}`, known variants: {:?}", s, Self::variants())) - } - } -} - impl Database { /// Returns all the variants of this enum to be shown in the cli. pub const fn variants() -> &'static [&'static str] { diff --git a/client/cli/src/params/database_params.rs b/client/cli/src/params/database_params.rs index e954b8cc3bc20..277b68f4f908a 100644 --- a/client/cli/src/params/database_params.rs +++ b/client/cli/src/params/database_params.rs @@ -23,13 +23,7 @@ use clap::Args; #[derive(Debug, Clone, PartialEq, Args)] pub struct DatabaseParams { /// Select database backend to use. - #[clap( - long, - alias = "db", - value_name = "DB", - ignore_case = true, - possible_values = Database::variants(), - )] + #[clap(long, alias = "db", value_name = "DB", value_enum)] pub database: Option, /// Limit the memory the database cache can use. diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs index 9b7e264ea3e2d..4ce865609ef61 100644 --- a/client/cli/src/params/import_params.rs +++ b/client/cli/src/params/import_params.rs @@ -57,7 +57,7 @@ pub struct ImportParams { #[clap( long = "wasm-execution", value_name = "METHOD", - possible_values = WasmExecutionMethod::variants(), + value_enum, ignore_case = true, default_value = DEFAULT_WASM_EXECUTION_METHOD, )] diff --git a/client/cli/src/params/mod.rs b/client/cli/src/params/mod.rs index 9fccce606b4e4..802f28c2a94cc 100644 --- a/client/cli/src/params/mod.rs +++ b/client/cli/src/params/mod.rs @@ -27,7 +27,7 @@ mod transaction_pool_params; use crate::arg_enums::{CryptoScheme, OutputType}; use clap::Args; -use sp_core::crypto::Ss58AddressFormat; +use sp_core::crypto::{Ss58AddressFormat, Ss58AddressFormatRegistry}; use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, NumberFor}, @@ -40,6 +40,20 @@ pub use crate::params::{ transaction_pool_params::*, }; +#[derive(Clone, Debug)] +struct FormatRegistryWrapper(Ss58AddressFormatRegistry); + +/// Parse Ss58AddressFormat +pub fn parse_ss58_address_format(x: &str) -> Result { + match Ss58AddressFormatRegistry::try_from(x) { + Ok(format_registry) => Ok(format_registry.into()), + Err(e) => Err(format!( + "Unable to parse variant. Known variants: {:?}", + Ss58AddressFormat::all_names() + )), + } +} + /// Wrapper type of `String` that holds an unsigned integer of arbitrary size, formatted as a /// decimal. #[derive(Debug, Clone)] @@ -138,9 +152,8 @@ pub struct NetworkSchemeFlag { short = 'n', long, value_name = "NETWORK", - possible_values = &Ss58AddressFormat::all_names()[..], ignore_case = true, - parse(try_from_str = Ss58AddressFormat::try_from), + value_parser = parse_ss58_address_format, )] pub network: Option, } diff --git a/utils/frame/benchmarking-cli/src/pallet/mod.rs b/utils/frame/benchmarking-cli/src/pallet/mod.rs index 4bf9c5198ef72..3195e2d25fdc8 100644 --- a/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -133,7 +133,7 @@ pub struct PalletCmd { #[clap( long = "wasm-execution", value_name = "METHOD", - possible_values = WasmExecutionMethod::variants(), + value_enum, ignore_case = true, default_value = DEFAULT_WASM_EXECUTION_METHOD, )] diff --git a/utils/frame/benchmarking-cli/src/storage/cmd.rs b/utils/frame/benchmarking-cli/src/storage/cmd.rs index 1d91e8f0b0517..3d4dad2a945ab 100644 --- a/utils/frame/benchmarking-cli/src/storage/cmd.rs +++ b/utils/frame/benchmarking-cli/src/storage/cmd.rs @@ -99,7 +99,7 @@ pub struct StorageParams { /// The `StateVersion` to use. Substrate `--dev` should use `V1` and Polkadot `V0`. /// Selecting the wrong version can corrupt the DB. - #[clap(long, possible_values = ["0", "1"])] + #[clap(long, value_parser = ["0", "1"])] pub state_version: u8, /// Trie cache size in bytes. diff --git a/utils/frame/frame-utilities-cli/src/pallet_id.rs b/utils/frame/frame-utilities-cli/src/pallet_id.rs index 4ad82a01c2433..1176c4c1c420c 100644 --- a/utils/frame/frame-utilities-cli/src/pallet_id.rs +++ b/utils/frame/frame-utilities-cli/src/pallet_id.rs @@ -37,8 +37,7 @@ pub struct PalletIdCmd { #[clap( long, value_name = "NETWORK", - possible_values = &Ss58AddressFormat::all_names()[..], - parse(try_from_str = Ss58AddressFormat::try_from), + value_parser = sc_cli::parse_ss58_address_format, ignore_case = true, )] pub network: Option, diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index 0ef610a64463a..92f8f5fa7ca96 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -399,7 +399,7 @@ pub struct SharedParams { #[clap( long = "wasm-execution", value_name = "METHOD", - possible_values = WasmExecutionMethod::variants(), + value_enum, ignore_case = true, default_value = DEFAULT_WASM_EXECUTION_METHOD, )] From e6889965c46e35e08b73d14ba31c07ece5ef6380 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Wed, 28 Sep 2022 16:11:59 +0200 Subject: [PATCH 05/20] Remove unwanted print --- client/cli/src/arg_enums.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index 4d664b3ffcc4f..b154d444a62a2 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -117,7 +117,6 @@ pub fn execution_method_from_cli( execution_method: WasmExecutionMethod, _instantiation_strategy: WasmtimeInstantiationStrategy, ) -> sc_service::config::WasmExecutionMethod { - println!("execution method: {:?}", execution_method); match execution_method { WasmExecutionMethod::Interpreted => sc_service::config::WasmExecutionMethod::Interpreted, #[cfg(feature = "wasmtime")] From f6fa5bcb8c78b4f166ffae1eeca272145301148a Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Thu, 29 Sep 2022 09:22:14 +0200 Subject: [PATCH 06/20] Add missing match branch --- client/cli/src/arg_enums.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index b154d444a62a2..6d187d1637c07 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -94,11 +94,13 @@ impl clap::ValueEnum for WasmExecutionMethod { /// /// The value is `None` for skipped variants. fn to_possible_value<'a>(&self) -> Option> { - Some(match self { + match self { #[cfg(feature = "wasmtime")] - WasmExecutionMethod::Compiled => PossibleValue::new("compiled"), - WasmExecutionMethod::Interpreted => PossibleValue::new(INTERPRETED_NAME), - }) + WasmExecutionMethod::Compiled => Some(PossibleValue::new("compiled")), + #[cfg(not(feature = "wasmtime"))] + WasmExecutionMethod::Compiled => None, + WasmExecutionMethod::Interpreted => Some(PossibleValue::new(INTERPRETED_NAME)), + } } } From 0cd492119f3b7f137a710abc6163a53cc8ed7f9c Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Wed, 5 Oct 2022 13:26:50 +0200 Subject: [PATCH 07/20] Update clap to 4.0.9 and make it compile --- Cargo.lock | 60 ++++++++----------- bin/node-template/node/Cargo.toml | 2 +- bin/node/bench/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 6 +- bin/node/cli/build.rs | 2 +- bin/node/inspect/Cargo.toml | 2 +- bin/node/inspect/src/cli.rs | 1 + bin/utils/chain-spec-builder/Cargo.toml | 2 +- bin/utils/subkey/Cargo.toml | 2 +- client/cli/Cargo.toml | 2 +- client/cli/src/arg_enums.rs | 26 ++++---- client/cli/src/commands/insert_key.rs | 2 +- client/cli/src/commands/run_cmd.rs | 4 +- client/cli/src/lib.rs | 14 ++--- client/cli/src/params/import_params.rs | 24 ++++---- client/cli/src/params/keystore_params.rs | 6 +- client/cli/src/params/mod.rs | 4 +- client/cli/src/params/network_params.rs | 16 ++--- client/cli/src/params/node_key_params.rs | 4 +- .../cli/src/params/offchain_worker_params.rs | 2 +- client/cli/src/params/shared_params.rs | 4 +- .../solution-type/fuzzer/Cargo.toml | 2 +- primitives/npos-elections/fuzzer/Cargo.toml | 2 +- utils/frame/benchmarking-cli/Cargo.toml | 2 +- .../frame/benchmarking-cli/src/pallet/mod.rs | 6 +- utils/frame/frame-utilities-cli/Cargo.toml | 2 +- .../generate-bags/node-runtime/Cargo.toml | 2 +- utils/frame/try-runtime/cli/Cargo.toml | 2 +- .../cli/src/commands/execute_block.rs | 2 - .../cli/src/commands/offchain_worker.rs | 2 - utils/frame/try-runtime/cli/src/lib.rs | 7 +-- 31 files changed, 100 insertions(+), 116 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5df90feb03e74..ce91104971f10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -920,7 +920,7 @@ name = "chain-spec-builder" version = "2.0.0" dependencies = [ "ansi_term", - "clap 3.2.22", + "clap 4.0.9", "node-cli", "rand 0.8.5", "sc-chain-spec", @@ -991,41 +991,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "bitflags", - "textwrap 0.11.0", + "textwrap", "unicode-width", ] [[package]] name = "clap" -version = "3.2.22" +version = "4.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" +checksum = "30607dd93c420c6f1f80b544be522a0238a7db35e6a12968d28910983fee0df0" dependencies = [ "atty", "bitflags", "clap_derive", "clap_lex", - "indexmap", "once_cell", "strsim", "termcolor", - "textwrap 0.15.1", ] [[package]] name = "clap_complete" -version = "3.0.2" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a394f7ec0715b42a4e52b294984c27c9a61f77c8d82f7774c5198350be143f19" +checksum = "11cba7abac9b56dfe2f035098cdb3a43946f276e6db83b72c4e692343f9aab9a" dependencies = [ - "clap 3.2.22", + "clap 4.0.9", ] [[package]] name = "clap_derive" -version = "3.2.18" +version = "4.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "a4a307492e1a34939f79d3b6b9650bd2b971513cd775436bf2b78defeb5af00b" dependencies = [ "heck", "proc-macro-error", @@ -1036,9 +1034,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" dependencies = [ "os_str_bytes", ] @@ -2147,7 +2145,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 3.2.22", + "clap 4.0.9", "comfy-table", "frame-benchmarking", "frame-support", @@ -2228,7 +2226,7 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 3.2.22", + "clap 4.0.9", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", @@ -4639,7 +4637,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes", - "clap 3.2.22", + "clap 4.0.9", "derive_more", "fs_extra", "futures", @@ -4678,7 +4676,7 @@ dependencies = [ "array-bytes", "assert_cmd", "async-std", - "clap 3.2.22", + "clap 4.0.9", "clap_complete", "criterion", "frame-benchmarking-cli", @@ -4795,7 +4793,7 @@ dependencies = [ name = "node-inspect" version = "0.9.0-dev" dependencies = [ - "clap 3.2.22", + "clap 4.0.9", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -4855,7 +4853,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 3.2.22", + "clap 4.0.9", "generate-bags", "kitchensink-runtime", ] @@ -4864,7 +4862,7 @@ dependencies = [ name = "node-template" version = "4.0.0-dev" dependencies = [ - "clap 3.2.22", + "clap 4.0.9", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -7059,9 +7057,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.39" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" dependencies = [ "unicode-ident", ] @@ -7921,7 +7919,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "chrono", - "clap 3.2.22", + "clap 4.0.9", "fdlimit", "futures", "libp2p", @@ -10025,7 +10023,7 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 3.2.22", + "clap 4.0.9", "honggfuzz", "parity-scale-codec", "rand 0.8.5", @@ -10522,7 +10520,7 @@ dependencies = [ name = "subkey" version = "2.0.2" dependencies = [ - "clap 3.2.22", + "clap 4.0.9", "sc-cli", ] @@ -10550,7 +10548,7 @@ dependencies = [ name = "substrate-frame-cli" version = "4.0.0-dev" dependencies = [ - "clap 3.2.22", + "clap 4.0.9", "frame-support", "frame-system", "sc-cli", @@ -10880,12 +10878,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "textwrap" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" - [[package]] name = "thiserror" version = "1.0.30" @@ -11296,7 +11288,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" name = "try-runtime-cli" version = "0.10.0-dev" dependencies = [ - "clap 3.2.22", + "clap 4.0.9", "frame-try-runtime", "jsonrpsee", "log", @@ -11346,7 +11338,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "digest 0.10.3", "rand 0.8.5", "static_assertions", diff --git a/bin/node-template/node/Cargo.toml b/bin/node-template/node/Cargo.toml index 47b058815672c..25eda3dd5d8c5 100644 --- a/bin/node-template/node/Cargo.toml +++ b/bin/node-template/node/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] name = "node-template" [dependencies] -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } sc-cli = { version = "0.10.0-dev", path = "../../../client/cli", features = ["wasmtime"] } sp-core = { version = "6.0.0", path = "../../../primitives/core" } diff --git a/bin/node/bench/Cargo.toml b/bin/node/bench/Cargo.toml index 64681ee213650..1abd6e818e968 100644 --- a/bin/node/bench/Cargo.toml +++ b/bin/node/bench/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/" [dependencies] array-bytes = "4.1" -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } log = "0.4.17" node-primitives = { version = "2.0.0", path = "../primitives" } node-testing = { version = "3.0.0-dev", path = "../testing" } diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 5f5b05b707c1a..3be292083c40a 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -35,7 +35,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] # third-party dependencies array-bytes = "4.1" -clap = { version = "3.2.22", features = ["derive", "deprecated"], optional = true } +clap = { version = "4.0.9", features = ["derive", "deprecated"], optional = true } codec = { package = "parity-scale-codec", version = "3.0.0" } serde = { version = "1.0.136", features = ["derive"] } jsonrpsee = { version = "0.15.1", features = ["server"] } @@ -136,8 +136,8 @@ remote-externalities = { path = "../../../utils/frame/remote-externalities" } pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" } [build-dependencies] -clap = { version = "3.2.22", optional = true } -clap_complete = { version = "3.0", optional = true } +clap = { version = "4.0.9", optional = true } +clap_complete = { version = "4.0.2", 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" } diff --git a/bin/node/cli/build.rs b/bin/node/cli/build.rs index 6a3d13dda6a00..e8142b297f1b2 100644 --- a/bin/node/cli/build.rs +++ b/bin/node/cli/build.rs @@ -25,7 +25,7 @@ fn main() { mod cli { include!("src/cli.rs"); - use clap::{ArgEnum, CommandFactory}; + use clap::{CommandFactory, ValueEnum}; 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}; diff --git a/bin/node/inspect/Cargo.toml b/bin/node/inspect/Cargo.toml index ede96a76206ce..67728b0aa08f0 100644 --- a/bin/node/inspect/Cargo.toml +++ b/bin/node/inspect/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "3.1.6", features = ["derive"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } codec = { package = "parity-scale-codec", version = "3.0.0" } thiserror = "1.0" sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" } diff --git a/bin/node/inspect/src/cli.rs b/bin/node/inspect/src/cli.rs index cc1f232e1fe0f..8b7026f44736a 100644 --- a/bin/node/inspect/src/cli.rs +++ b/bin/node/inspect/src/cli.rs @@ -18,6 +18,7 @@ //! Structs to easily compose inspect sub-command for CLI. +use clap::{arg, command}; use sc_cli::{ImportParams, SharedParams}; /// The `inspect` command used to print decoded chain data. diff --git a/bin/utils/chain-spec-builder/Cargo.toml b/bin/utils/chain-spec-builder/Cargo.toml index ae13a2052afa9..72fad4d09108a 100644 --- a/bin/utils/chain-spec-builder/Cargo.toml +++ b/bin/utils/chain-spec-builder/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] ansi_term = "0.12.1" -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } rand = "0.8" node-cli = { version = "3.0.0-dev", path = "../../node/cli" } sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" } diff --git a/bin/utils/subkey/Cargo.toml b/bin/utils/subkey/Cargo.toml index 68e60be903c45..d4d39d3f37270 100644 --- a/bin/utils/subkey/Cargo.toml +++ b/bin/utils/subkey/Cargo.toml @@ -17,5 +17,5 @@ path = "src/main.rs" name = "subkey" [dependencies] -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" } diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 496aa454e55b3..370f0ca805c82 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" chrono = "0.4.10" -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated", "string"] } fdlimit = "0.2.1" futures = "0.3.21" libp2p = "0.46.1" diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index 6d187d1637c07..0286327793a4d 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -16,12 +16,12 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! Definitions of [`ArgEnum`] types. +//! Definitions of [`ValueEnum`] types. -use clap::{ArgEnum, PossibleValue}; +use clap::{builder::PossibleValue, ValueEnum}; /// The instantiation strategy to use in compiled mode. -#[derive(Debug, Clone, Copy, ArgEnum)] +#[derive(Debug, Clone, Copy, ValueEnum)] #[clap(rename_all = "kebab-case")] pub enum WasmtimeInstantiationStrategy { /// Pool the instances to avoid initializing everything from scratch @@ -93,7 +93,7 @@ impl clap::ValueEnum for WasmExecutionMethod { /// The canonical argument value. /// /// The value is `None` for skipped variants. - fn to_possible_value<'a>(&self) -> Option> { + fn to_possible_value(&self) -> Option { match self { #[cfg(feature = "wasmtime")] WasmExecutionMethod::Compiled => Some(PossibleValue::new("compiled")), @@ -152,7 +152,7 @@ pub const DEFAULT_WASM_EXECUTION_METHOD: &str = "compiled"; pub const DEFAULT_WASM_EXECUTION_METHOD: &str = "interpreted-i-know-what-i-do"; #[allow(missing_docs)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] #[clap(rename_all = "kebab-case")] pub enum TracingReceiver { /// Output the tracing records using the log. @@ -168,7 +168,7 @@ impl Into for TracingReceiver { } /// The type of the node key. -#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] #[clap(rename_all = "kebab-case")] pub enum NodeKeyType { /// Use ed25519. @@ -176,7 +176,7 @@ pub enum NodeKeyType { } /// The crypto scheme to use. -#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] #[clap(rename_all = "kebab-case")] pub enum CryptoScheme { /// Use ed25519. @@ -188,7 +188,7 @@ pub enum CryptoScheme { } /// The type of the output format. -#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] #[clap(rename_all = "kebab-case")] pub enum OutputType { /// Output as json. @@ -198,7 +198,7 @@ pub enum OutputType { } /// How to execute blocks -#[derive(Debug, Copy, Clone, PartialEq, Eq, ArgEnum)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] #[clap(rename_all = "kebab-case")] pub enum ExecutionStrategy { /// Execute with native build (if available, WebAssembly otherwise). @@ -224,7 +224,7 @@ impl Into for ExecutionStrategy { /// Available RPC methods. #[allow(missing_docs)] -#[derive(Debug, Copy, Clone, PartialEq, ArgEnum)] +#[derive(Debug, Copy, Clone, PartialEq, ValueEnum)] #[clap(rename_all = "kebab-case")] pub enum RpcMethods { /// Expose every RPC method only when RPC is listening on `localhost`, @@ -259,7 +259,7 @@ pub enum Database { /// instance of ParityDb Auto, /// ParityDb. - #[clap(alias = "paritydb-experimental")] + #[clap(name = "paritydb-experimental")] ParityDbDeprecated, } @@ -278,7 +278,7 @@ impl Database { /// Whether off-chain workers are enabled. #[allow(missing_docs)] -#[derive(Debug, Clone, ArgEnum)] +#[derive(Debug, Clone, ValueEnum)] #[clap(rename_all = "kebab-case")] pub enum OffchainWorkerEnabled { /// Always have offchain worker enabled. @@ -290,7 +290,7 @@ pub enum OffchainWorkerEnabled { } /// Syncing mode. -#[derive(Debug, Clone, Copy, ArgEnum, PartialEq)] +#[derive(Debug, Clone, Copy, ValueEnum, PartialEq)] #[clap(rename_all = "kebab-case")] pub enum SyncMode { /// Full sync. Download end verify all blocks. diff --git a/client/cli/src/commands/insert_key.rs b/client/cli/src/commands/insert_key.rs index 5029ecd29248c..ffbc57647fd08 100644 --- a/client/cli/src/commands/insert_key.rs +++ b/client/cli/src/commands/insert_key.rs @@ -50,7 +50,7 @@ pub struct InsertKeyCmd { pub keystore_params: KeystoreParams, /// The cryptography scheme that should be used to generate the key out of the given URI. - #[clap(long, value_name = "SCHEME", arg_enum, ignore_case = true)] + #[clap(long, value_name = "SCHEME", value_enum, ignore_case = true)] pub scheme: CryptoScheme, } diff --git a/client/cli/src/commands/run_cmd.rs b/client/cli/src/commands/run_cmd.rs index 7cdeea03f2811..f4ade909d3b5a 100644 --- a/client/cli/src/commands/run_cmd.rs +++ b/client/cli/src/commands/run_cmd.rs @@ -74,7 +74,7 @@ pub struct RunCmd { #[clap( long, value_name = "METHOD SET", - arg_enum, + value_enum, ignore_case = true, default_value = "auto", verbatim_doc_comment @@ -262,7 +262,7 @@ pub struct RunCmd { /// which includes: database, node key and keystore. /// /// When `--dev` is given and no explicit `--base-path`, this option is implied. - #[clap(long, conflicts_with = "base-path")] + #[clap(long, conflicts_with = "base_path")] pub tmp: bool, } diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index e01befbef41a2..c1d3d9af83316 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -129,9 +129,9 @@ pub trait SubstrateCli: Sized { let about = Self::description(); let app = app .name(name) - .author(author.as_str()) - .about(about.as_str()) - .version(full_version.as_str()) + .author(author) + .about(about) + .version(full_version) .propagate_version(true) .args_conflicts_with_subcommands(true) .subcommand_negates_reqs(true); @@ -155,7 +155,7 @@ pub trait SubstrateCli: Sized { /// used. It will return a [`clap::Error`], where the [`clap::Error::kind`] is a /// [`clap::ErrorKind::DisplayHelp`] or [`clap::ErrorKind::DisplayVersion`] respectively. /// You must call [`clap::Error::exit`] or perform a [`std::process::exit`]. - fn try_from_iter(iter: I) -> clap::Result + fn try_from_iter(iter: I) -> clap::error::Result where Self: Parser + Sized, I: IntoIterator, @@ -169,11 +169,7 @@ pub trait SubstrateCli: Sized { let name = Self::executable_name(); let author = Self::author(); let about = Self::description(); - let app = app - .name(name) - .author(author.as_str()) - .about(about.as_str()) - .version(full_version.as_str()); + let app = app.name(name).author(author).about(about).version(full_version); let matches = app.try_get_matches_from(iter)?; diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs index 4ce865609ef61..e8264384ef6b4 100644 --- a/client/cli/src/params/import_params.rs +++ b/client/cli/src/params/import_params.rs @@ -80,7 +80,7 @@ pub struct ImportParams { long, value_name = "STRATEGY", default_value_t = DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, - arg_enum, + value_enum, )] pub wasmtime_instantiation_strategy: WasmtimeInstantiationStrategy, @@ -168,39 +168,39 @@ impl ImportParams { pub struct ExecutionStrategiesParams { /// The means of execution used when calling into the runtime for importing blocks as /// part of an initial sync. - #[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)] + #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution_syncing: Option, /// The means of execution used when calling into the runtime for general block import /// (including locally authored blocks). - #[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)] + #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution_import_block: Option, /// The means of execution used when calling into the runtime while constructing blocks. - #[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)] + #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution_block_construction: Option, /// The means of execution used when calling into the runtime while using an off-chain worker. - #[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)] + #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution_offchain_worker: Option, /// The means of execution used when calling into the runtime while not syncing, importing or /// constructing blocks. - #[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)] + #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution_other: Option, /// The execution strategy that should be used by all execution contexts. #[clap( long, value_name = "STRATEGY", - arg_enum, + value_enum, ignore_case = true, conflicts_with_all = &[ - "execution-other", - "execution-offchain-worker", - "execution-block-construction", - "execution-import-block", - "execution-syncing", + "execution_other", + "execution_offchain_worker", + "execution_block_construction", + "execution_import_block", + "execution_syncing", ] )] pub execution: Option, diff --git a/client/cli/src/params/keystore_params.rs b/client/cli/src/params/keystore_params.rs index a298a9abaca8f..a53643aa1490d 100644 --- a/client/cli/src/params/keystore_params.rs +++ b/client/cli/src/params/keystore_params.rs @@ -40,7 +40,7 @@ pub struct KeystoreParams { pub keystore_path: Option, /// Use interactive shell for entering the password used by the keystore. - #[clap(long, conflicts_with_all = &["password", "password-filename"])] + #[clap(long, conflicts_with_all = &["password", "password_filename"])] pub password_interactive: bool, /// Password used by the keystore. This allows appending an extra user-defined secret to the @@ -48,7 +48,7 @@ pub struct KeystoreParams { #[clap( long, value_parser = secret_string_from_str, - conflicts_with_all = &["password-interactive", "password-filename"] + conflicts_with_all = &["password_interactive", "password_filename"] )] pub password: Option, @@ -57,7 +57,7 @@ pub struct KeystoreParams { long, value_name = "PATH", value_parser, - conflicts_with_all = &["password-interactive", "password"] + conflicts_with_all = &["password_interactive", "password"] )] pub password_filename: Option, } diff --git a/client/cli/src/params/mod.rs b/client/cli/src/params/mod.rs index 802f28c2a94cc..9df8ada11e1cd 100644 --- a/client/cli/src/params/mod.rs +++ b/client/cli/src/params/mod.rs @@ -132,7 +132,7 @@ impl BlockNumberOrHash { #[derive(Debug, Clone, Args)] pub struct CryptoSchemeFlag { /// cryptography scheme - #[clap(long, value_name = "SCHEME", arg_enum, ignore_case = true, default_value = "sr25519")] + #[clap(long, value_name = "SCHEME", value_enum, ignore_case = true, default_value = "sr25519")] pub scheme: CryptoScheme, } @@ -140,7 +140,7 @@ pub struct CryptoSchemeFlag { #[derive(Debug, Clone, Args)] pub struct OutputTypeFlag { /// output format - #[clap(long, value_name = "FORMAT", arg_enum, ignore_case = true, default_value = "text")] + #[clap(long, value_name = "FORMAT", value_enum, ignore_case = true, default_value = "text")] pub output_type: OutputType, } diff --git a/client/cli/src/params/network_params.rs b/client/cli/src/params/network_params.rs index 0450b5f0e2566..2abed2dd3df25 100644 --- a/client/cli/src/params/network_params.rs +++ b/client/cli/src/params/network_params.rs @@ -33,11 +33,11 @@ use std::{borrow::Cow, path::PathBuf}; #[derive(Debug, Clone, Args)] pub struct NetworkParams { /// Specify a list of bootnodes. - #[clap(long, value_name = "ADDR", multiple_values(true))] + #[clap(long, value_name = "ADDR", num_args = 0..)] pub bootnodes: Vec, /// Specify a list of reserved node addresses. - #[clap(long, value_name = "ADDR", multiple_values(true))] + #[clap(long, value_name = "ADDR", num_args = 0..)] pub reserved_nodes: Vec, /// Whether to only synchronize the chain with reserved nodes. @@ -53,7 +53,7 @@ pub struct NetworkParams { /// The public address that other nodes will use to connect to it. /// This can be used if there's a proxy in front of this node. - #[clap(long, value_name = "PUBLIC_ADDR", multiple_values(true))] + #[clap(long, value_name = "PUBLIC_ADDR", num_args = 0..)] pub public_addr: Vec, /// Listen on this multiaddress. @@ -61,24 +61,24 @@ pub struct NetworkParams { /// By default: /// If `--validator` is passed: `/ip4/0.0.0.0/tcp/` and `/ip6/[::]/tcp/`. /// Otherwise: `/ip4/0.0.0.0/tcp//ws` and `/ip6/[::]/tcp//ws`. - #[clap(long, value_name = "LISTEN_ADDR", multiple_values(true))] + #[clap(long, value_name = "LISTEN_ADDR", num_args = 0..)] pub listen_addr: Vec, /// Specify p2p protocol TCP port. - #[clap(long, value_name = "PORT", conflicts_with_all = &[ "listen-addr" ])] + #[clap(long, value_name = "PORT", conflicts_with_all = &[ "listen_addr" ])] pub port: Option, /// Always forbid connecting to private IPv4 addresses (as specified in /// [RFC1918](https://tools.ietf.org/html/rfc1918)), unless the address was passed with /// `--reserved-nodes` or `--bootnodes`. Enabled by default for chains marked as "live" in /// their chain specifications. - #[clap(long, conflicts_with_all = &["allow-private-ipv4"])] + #[clap(long, conflicts_with_all = &["allow_private_ipv4"])] pub no_private_ipv4: bool, /// Always accept connecting to private IPv4 addresses (as specified in /// [RFC1918](https://tools.ietf.org/html/rfc1918)). Enabled by default for chains marked as /// "local" in their chain specifications, or when `--dev` is passed. - #[clap(long, conflicts_with_all = &["no-private-ipv4"])] + #[clap(long, conflicts_with_all = &["no_private_ipv4"])] pub allow_private_ipv4: bool, /// Specify the number of outgoing connections we're trying to maintain. @@ -137,7 +137,7 @@ pub struct NetworkParams { /// - `warp`: Download the latest state and proof. #[clap( long, - arg_enum, + value_enum, value_name = "SYNC_MODE", default_value = "full", ignore_case = true, diff --git a/client/cli/src/params/node_key_params.rs b/client/cli/src/params/node_key_params.rs index 00ce9e8027aab..5d42ab80b0429 100644 --- a/client/cli/src/params/node_key_params.rs +++ b/client/cli/src/params/node_key_params.rs @@ -66,7 +66,7 @@ pub struct NodeKeyParams { /// /// The node's secret key determines the corresponding public key and hence the /// 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", value_enum, ignore_case = true, default_value = "ed25519")] pub node_key_type: NodeKeyType, /// The file from which to read the node's secret key to use for libp2p networking. @@ -122,7 +122,7 @@ fn parse_ed25519_secret(hex: &str) -> error::Result. - #[clap(short = 'l', long, value_name = "LOG_PATTERN", multiple_values(true))] + #[clap(short = 'l', long, value_name = "LOG_PATTERN", num_args = 0..)] pub log: Vec, /// Enable detailed log output. @@ -76,7 +76,7 @@ pub struct SharedParams { pub tracing_targets: Option, /// Receiver to process tracing messages. - #[clap(long, value_name = "RECEIVER", arg_enum, ignore_case = true, default_value = "log")] + #[clap(long, value_name = "RECEIVER", value_enum, ignore_case = true, default_value = "log")] pub tracing_receiver: TracingReceiver, } diff --git a/frame/election-provider-support/solution-type/fuzzer/Cargo.toml b/frame/election-provider-support/solution-type/fuzzer/Cargo.toml index 8e04e8c232d4a..d662ced515378 100644 --- a/frame/election-provider-support/solution-type/fuzzer/Cargo.toml +++ b/frame/election-provider-support/solution-type/fuzzer/Cargo.toml @@ -13,7 +13,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } honggfuzz = "0.5" rand = { version = "0.8", features = ["std", "small_rng"] } diff --git a/primitives/npos-elections/fuzzer/Cargo.toml b/primitives/npos-elections/fuzzer/Cargo.toml index 271e77450f5f2..cbbe4851d3642 100644 --- a/primitives/npos-elections/fuzzer/Cargo.toml +++ b/primitives/npos-elections/fuzzer/Cargo.toml @@ -14,7 +14,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } honggfuzz = "0.5" rand = { version = "0.8", features = ["std", "small_rng"] } diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index 1af6dc878cb11..eb01d4ab964c1 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" chrono = "0.4" -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } codec = { package = "parity-scale-codec", version = "3.0.0" } comfy-table = { version = "6.0.0", default-features = false } handlebars = "4.2.2" diff --git a/utils/frame/benchmarking-cli/src/pallet/mod.rs b/utils/frame/benchmarking-cli/src/pallet/mod.rs index 3195e2d25fdc8..629a931896e0d 100644 --- a/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -69,7 +69,7 @@ pub struct PalletCmd { pub json_output: bool, /// Write the raw results in JSON format into the given file. - #[clap(long, conflicts_with = "json-output")] + #[clap(long, conflicts_with = "json_output")] pub json_file: Option, /// Don't print the median-slopes linear regression analysis. @@ -126,7 +126,7 @@ pub struct PalletCmd { pub shared_params: sc_cli::SharedParams, /// The execution strategy that should be used for benchmarks. - #[clap(long, value_name = "STRATEGY", arg_enum, ignore_case = true)] + #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution: Option, /// Method for executing Wasm runtime code. @@ -146,7 +146,7 @@ pub struct PalletCmd { long = "wasm-instantiation-strategy", value_name = "STRATEGY", default_value_t = DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, - arg_enum, + value_enum, )] pub wasmtime_instantiation_strategy: WasmtimeInstantiationStrategy, diff --git a/utils/frame/frame-utilities-cli/Cargo.toml b/utils/frame/frame-utilities-cli/Cargo.toml index 91cb5fc24efde..d5cc8c1d4d8a2 100644 --- a/utils/frame/frame-utilities-cli/Cargo.toml +++ b/utils/frame/frame-utilities-cli/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/substrate-frame-cli" readme = "README.md" [dependencies] -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } frame-support = { version = "4.0.0-dev", path = "../../../frame/support" } frame-system = { version = "4.0.0-dev", path = "../../../frame/system" } sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" } diff --git a/utils/frame/generate-bags/node-runtime/Cargo.toml b/utils/frame/generate-bags/node-runtime/Cargo.toml index 96af7d31ed67e..0ad6d574302f2 100644 --- a/utils/frame/generate-bags/node-runtime/Cargo.toml +++ b/utils/frame/generate-bags/node-runtime/Cargo.toml @@ -14,4 +14,4 @@ kitchensink-runtime = { version = "3.0.0-dev", path = "../../../../bin/node/runt generate-bags = { version = "4.0.0-dev", path = "../" } # third-party -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } diff --git a/utils/frame/try-runtime/cli/Cargo.toml b/utils/frame/try-runtime/cli/Cargo.toml index f54f14844d3ba..bea21d857e28e 100644 --- a/utils/frame/try-runtime/cli/Cargo.toml +++ b/utils/frame/try-runtime/cli/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "3.2.22", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } log = "0.4.17" parity-scale-codec = "3.0.0" serde = "1.0.136" diff --git a/utils/frame/try-runtime/cli/src/commands/execute_block.rs b/utils/frame/try-runtime/cli/src/commands/execute_block.rs index bc5ea1db140fe..711de2127b404 100644 --- a/utils/frame/try-runtime/cli/src/commands/execute_block.rs +++ b/utils/frame/try-runtime/cli/src/commands/execute_block.rs @@ -58,7 +58,6 @@ pub struct ExecuteBlockCmd { /// the `state::at` is. Only use this (with care) when combined with a snapshot. #[clap( long, - multiple_values = false, value_parser = crate::parse::hash )] block_at: Option, @@ -69,7 +68,6 @@ pub struct ExecuteBlockCmd { /// the `state::uri` is. Only use this (with care) when combined with a snapshot. #[clap( long, - multiple_values = false, value_parser = crate::parse::url )] block_ws_uri: Option, diff --git a/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs b/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs index b660d0dfad969..13788dd8313ea 100644 --- a/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs +++ b/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs @@ -40,7 +40,6 @@ pub struct OffchainWorkerCmd { /// the `state::at` is. Only use this (with care) when combined with a snapshot. #[clap( long, - multiple_values = false, value_parser = parse::hash )] header_at: Option, @@ -51,7 +50,6 @@ pub struct OffchainWorkerCmd { /// the `state::uri` is. Only use this (with care) when combined with a snapshot. #[clap( long, - multiple_values = false, value_parser = parse::url )] header_ws_uri: Option, diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index 92f8f5fa7ca96..f6a7223b146db 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -392,7 +392,7 @@ pub struct SharedParams { pub shared_params: sc_cli::SharedParams, /// 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", value_enum, ignore_case = true, default_value = "wasm")] pub execution: ExecutionStrategy, /// Type of wasm execution used. @@ -412,7 +412,7 @@ pub struct SharedParams { long = "wasm-instantiation-strategy", value_name = "STRATEGY", default_value_t = DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, - arg_enum, + value_enum, )] pub wasmtime_instantiation_strategy: WasmtimeInstantiationStrategy, @@ -470,7 +470,6 @@ pub enum State { #[clap( short, long, - multiple_values = false, value_parser = parse::hash, )] at: Option, @@ -481,7 +480,7 @@ pub enum State { /// A pallet to scrape. Can be provided multiple times. If empty, entire chain state will /// be scraped. - #[clap(short, long, multiple_values = true)] + #[clap(short, long, num_args = 0..)] pallet: Vec, /// Fetch the child-keys as well. From ba302c4566956383ca21a8ad3920c9e30eb49244 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Wed, 5 Oct 2022 14:49:05 +0200 Subject: [PATCH 08/20] Replace deprecated `clap` macro with `command` and `value` --- bin/node-template/node/src/cli.rs | 6 ++--- bin/node/bench/src/main.rs | 2 +- bin/node/cli/src/cli.rs | 8 +++---- bin/utils/chain-spec-builder/src/main.rs | 2 +- bin/utils/subkey/src/lib.rs | 2 +- client/cli/src/arg_enums.rs | 22 +++++++++---------- client/cli/src/commands/generate.rs | 2 +- client/cli/src/commands/generate_node_key.rs | 2 +- client/cli/src/commands/insert_key.rs | 2 +- client/cli/src/commands/inspect_key.rs | 2 +- client/cli/src/commands/inspect_node_key.rs | 2 +- client/cli/src/commands/sign.rs | 2 +- client/cli/src/commands/vanity.rs | 2 +- client/cli/src/commands/verify.rs | 2 +- .../npos-elections/fuzzer/src/phragmen_pjr.rs | 2 +- .../frame/benchmarking-cli/src/pallet/mod.rs | 4 ++-- .../frame/benchmarking-cli/src/shared/mod.rs | 2 +- .../frame-utilities-cli/src/pallet_id.rs | 2 +- .../cli/src/commands/on_runtime_upgrade.rs | 2 +- 19 files changed, 35 insertions(+), 35 deletions(-) diff --git a/bin/node-template/node/src/cli.rs b/bin/node-template/node/src/cli.rs index 4ab4d34210c98..dd610477ac469 100644 --- a/bin/node-template/node/src/cli.rs +++ b/bin/node-template/node/src/cli.rs @@ -2,7 +2,7 @@ use sc_cli::RunCmd; #[derive(Debug, clap::Parser)] pub struct Cli { - #[clap(subcommand)] + #[command(subcommand)] pub subcommand: Option, #[clap(flatten)] @@ -12,7 +12,7 @@ pub struct Cli { #[derive(Debug, clap::Subcommand)] pub enum Subcommand { /// Key management cli utilities - #[clap(subcommand)] + #[command(subcommand)] Key(sc_cli::KeySubcommand), /// Build a chain specification. @@ -37,7 +37,7 @@ pub enum Subcommand { Revert(sc_cli::RevertCmd), /// Sub-commands concerned with benchmarking. - #[clap(subcommand)] + #[command(subcommand)] Benchmark(frame_benchmarking_cli::BenchmarkCmd), /// Try some command against runtime state. diff --git a/bin/node/bench/src/main.rs b/bin/node/bench/src/main.rs index d97c7af26535b..df86fe27a6623 100644 --- a/bin/node/bench/src/main.rs +++ b/bin/node/bench/src/main.rs @@ -43,7 +43,7 @@ use crate::{ }; #[derive(Debug, Parser)] -#[clap(name = "node-bench", about = "Node integration benchmarks")] +#[command(name = "node-bench", about = "Node integration benchmarks")] struct Opt { /// Show list of all available benchmarks. /// diff --git a/bin/node/cli/src/cli.rs b/bin/node/cli/src/cli.rs index 5b2977599bab0..bf830cb1e7d61 100644 --- a/bin/node/cli/src/cli.rs +++ b/bin/node/cli/src/cli.rs @@ -20,7 +20,7 @@ #[derive(Debug, clap::Parser)] pub struct Cli { /// Possible subcommand with parameters. - #[clap(subcommand)] + #[command(subcommand)] pub subcommand: Option, #[allow(missing_docs)] @@ -42,7 +42,7 @@ pub struct Cli { #[derive(Debug, clap::Subcommand)] pub enum Subcommand { /// The custom inspect subcommmand for decoding blocks and extrinsics. - #[clap( + #[command( name = "inspect", about = "Decode given block or extrinsic using current native runtime." )] @@ -50,7 +50,7 @@ pub enum Subcommand { /// Sub-commands concerned with benchmarking. /// The pallet benchmarking moved to the `pallet` sub-command. - #[clap(subcommand)] + #[command(subcommand)] Benchmark(frame_benchmarking_cli::BenchmarkCmd), /// Try some command against runtime state. @@ -62,7 +62,7 @@ pub enum Subcommand { TryRuntime, /// Key management cli utilities - #[clap(subcommand)] + #[command(subcommand)] Key(sc_cli::KeySubcommand), /// Verify a signature for a message, provided on STDIN, with a given (public or secret) key. diff --git a/bin/utils/chain-spec-builder/src/main.rs b/bin/utils/chain-spec-builder/src/main.rs index 641416154115b..56c76f2401621 100644 --- a/bin/utils/chain-spec-builder/src/main.rs +++ b/bin/utils/chain-spec-builder/src/main.rs @@ -37,7 +37,7 @@ use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; /// A utility to easily create a testnet chain spec definition with a given set /// of authorities and endowed accounts and/or generate random accounts. #[derive(Parser)] -#[clap(rename_all = "kebab-case")] +#[command(rename_all = "kebab-case")] enum ChainSpecBuilder { /// Create a new chain spec with the given authorities, endowed and sudo /// accounts. diff --git a/bin/utils/subkey/src/lib.rs b/bin/utils/subkey/src/lib.rs index 6773ba822340f..280b90848fbf5 100644 --- a/bin/utils/subkey/src/lib.rs +++ b/bin/utils/subkey/src/lib.rs @@ -23,7 +23,7 @@ use sc_cli::{ }; #[derive(Debug, Parser)] -#[clap( +#[command( name = "subkey", author = "Parity Team ", about = "Utility for generating and restoring with Substrate keys", diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index 0286327793a4d..8b03330cac325 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -22,7 +22,7 @@ use clap::{builder::PossibleValue, ValueEnum}; /// The instantiation strategy to use in compiled mode. #[derive(Debug, Clone, Copy, ValueEnum)] -#[clap(rename_all = "kebab-case")] +#[value(rename_all = "kebab-case")] pub enum WasmtimeInstantiationStrategy { /// Pool the instances to avoid initializing everything from scratch /// on each instantiation. Use copy-on-write memory when possible. @@ -153,7 +153,7 @@ pub const DEFAULT_WASM_EXECUTION_METHOD: &str = "interpreted-i-know-what-i-do"; #[allow(missing_docs)] #[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] -#[clap(rename_all = "kebab-case")] +#[value(rename_all = "kebab-case")] pub enum TracingReceiver { /// Output the tracing records using the log. Log, @@ -169,7 +169,7 @@ impl Into for TracingReceiver { /// The type of the node key. #[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] -#[clap(rename_all = "kebab-case")] +#[value(rename_all = "kebab-case")] pub enum NodeKeyType { /// Use ed25519. Ed25519, @@ -177,7 +177,7 @@ pub enum NodeKeyType { /// The crypto scheme to use. #[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] -#[clap(rename_all = "kebab-case")] +#[value(rename_all = "kebab-case")] pub enum CryptoScheme { /// Use ed25519. Ed25519, @@ -189,7 +189,7 @@ pub enum CryptoScheme { /// The type of the output format. #[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] -#[clap(rename_all = "kebab-case")] +#[value(rename_all = "kebab-case")] pub enum OutputType { /// Output as json. Json, @@ -199,7 +199,7 @@ pub enum OutputType { /// How to execute blocks #[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] -#[clap(rename_all = "kebab-case")] +#[value(rename_all = "kebab-case")] pub enum ExecutionStrategy { /// Execute with native build (if available, WebAssembly otherwise). Native, @@ -225,7 +225,7 @@ impl Into for ExecutionStrategy { /// Available RPC methods. #[allow(missing_docs)] #[derive(Debug, Copy, Clone, PartialEq, ValueEnum)] -#[clap(rename_all = "kebab-case")] +#[value(rename_all = "kebab-case")] pub enum RpcMethods { /// Expose every RPC method only when RPC is listening on `localhost`, /// otherwise serve only safe RPC methods. @@ -248,7 +248,7 @@ impl Into for RpcMethods { /// Database backend #[derive(Debug, Clone, PartialEq, Copy, clap::ValueEnum)] -#[clap(rename_all = "lower")] +#[value(rename_all = "lower")] pub enum Database { /// Facebooks RocksDB #[cfg(feature = "rocksdb")] @@ -259,7 +259,7 @@ pub enum Database { /// instance of ParityDb Auto, /// ParityDb. - #[clap(name = "paritydb-experimental")] + #[value(name = "paritydb-experimental")] ParityDbDeprecated, } @@ -279,7 +279,7 @@ impl Database { /// Whether off-chain workers are enabled. #[allow(missing_docs)] #[derive(Debug, Clone, ValueEnum)] -#[clap(rename_all = "kebab-case")] +#[value(rename_all = "kebab-case")] pub enum OffchainWorkerEnabled { /// Always have offchain worker enabled. Always, @@ -291,7 +291,7 @@ pub enum OffchainWorkerEnabled { /// Syncing mode. #[derive(Debug, Clone, Copy, ValueEnum, PartialEq)] -#[clap(rename_all = "kebab-case")] +#[value(rename_all = "kebab-case")] pub enum SyncMode { /// Full sync. Download end verify all blocks. Full, diff --git a/client/cli/src/commands/generate.rs b/client/cli/src/commands/generate.rs index 5b1b708f8669c..46f731ebba5b0 100644 --- a/client/cli/src/commands/generate.rs +++ b/client/cli/src/commands/generate.rs @@ -25,7 +25,7 @@ use clap::Parser; /// The `generate` command #[derive(Debug, Clone, Parser)] -#[clap(name = "generate", about = "Generate a random account")] +#[command(name = "generate", about = "Generate a random account")] pub struct GenerateCmd { /// The number of words in the phrase to generate. One of 12 (default), 15, 18, 21 and 24. #[clap(short = 'w', long, value_name = "WORDS")] diff --git a/client/cli/src/commands/generate_node_key.rs b/client/cli/src/commands/generate_node_key.rs index 3afd99d60a123..fdef154e29146 100644 --- a/client/cli/src/commands/generate_node_key.rs +++ b/client/cli/src/commands/generate_node_key.rs @@ -28,7 +28,7 @@ use std::{ /// The `generate-node-key` command #[derive(Debug, Parser)] -#[clap( +#[command( name = "generate-node-key", about = "Generate a random node key, write it to a file or stdout \ and write the corresponding peer-id to stderr" diff --git a/client/cli/src/commands/insert_key.rs b/client/cli/src/commands/insert_key.rs index ffbc57647fd08..ca70409f2c459 100644 --- a/client/cli/src/commands/insert_key.rs +++ b/client/cli/src/commands/insert_key.rs @@ -29,7 +29,7 @@ use std::sync::Arc; /// The `insert` command #[derive(Debug, Clone, Parser)] -#[clap(name = "insert", about = "Insert a key to the keystore of a node.")] +#[command(name = "insert", about = "Insert a key to the keystore of a node.")] pub struct InsertKeyCmd { /// The secret key URI. /// If the value is a file, the file content is used as URI. diff --git a/client/cli/src/commands/inspect_key.rs b/client/cli/src/commands/inspect_key.rs index 59f105dc52a5c..f7193745e0eb1 100644 --- a/client/cli/src/commands/inspect_key.rs +++ b/client/cli/src/commands/inspect_key.rs @@ -27,7 +27,7 @@ use std::str::FromStr; /// The `inspect` command #[derive(Debug, Parser)] -#[clap( +#[command( name = "inspect", about = "Gets a public key and a SS58 address from the provided Secret URI" )] diff --git a/client/cli/src/commands/inspect_node_key.rs b/client/cli/src/commands/inspect_node_key.rs index a9dff9c760d33..a83c1a98362a8 100644 --- a/client/cli/src/commands/inspect_node_key.rs +++ b/client/cli/src/commands/inspect_node_key.rs @@ -28,7 +28,7 @@ use std::{ /// The `inspect-node-key` command #[derive(Debug, Parser)] -#[clap( +#[command( name = "inspect-node-key", about = "Load a node key from a file or stdin and print the corresponding peer-id." )] diff --git a/client/cli/src/commands/sign.rs b/client/cli/src/commands/sign.rs index 7d93390326717..33fecc46bdb0b 100644 --- a/client/cli/src/commands/sign.rs +++ b/client/cli/src/commands/sign.rs @@ -23,7 +23,7 @@ use sp_core::crypto::SecretString; /// The `sign` command #[derive(Debug, Clone, Parser)] -#[clap(name = "sign", about = "Sign a message, with a given (secret) key")] +#[command(name = "sign", about = "Sign a message, with a given (secret) key")] pub struct SignCmd { /// The secret key URI. /// If the value is a file, the file content is used as URI. diff --git a/client/cli/src/commands/vanity.rs b/client/cli/src/commands/vanity.rs index f61760c0308e9..bb4cec1d770d4 100644 --- a/client/cli/src/commands/vanity.rs +++ b/client/cli/src/commands/vanity.rs @@ -29,7 +29,7 @@ use utils::print_from_uri; /// The `vanity` command #[derive(Debug, Clone, Parser)] -#[clap(name = "vanity", about = "Generate a seed that provides a vanity address")] +#[command(name = "vanity", about = "Generate a seed that provides a vanity address")] pub struct VanityCmd { /// Desired pattern #[clap(long, value_parser = assert_non_empty_string)] diff --git a/client/cli/src/commands/verify.rs b/client/cli/src/commands/verify.rs index 6389cdbde2c17..2877a94400f95 100644 --- a/client/cli/src/commands/verify.rs +++ b/client/cli/src/commands/verify.rs @@ -24,7 +24,7 @@ use sp_core::crypto::{ByteArray, Ss58Codec}; /// The `verify` command #[derive(Debug, Clone, Parser)] -#[clap( +#[command( name = "verify", about = "Verify a signature for a message, provided on STDIN, with a given (public or secret) key" )] diff --git a/primitives/npos-elections/fuzzer/src/phragmen_pjr.rs b/primitives/npos-elections/fuzzer/src/phragmen_pjr.rs index 2396fdfa3b40e..af2b6a36819df 100644 --- a/primitives/npos-elections/fuzzer/src/phragmen_pjr.rs +++ b/primitives/npos-elections/fuzzer/src/phragmen_pjr.rs @@ -68,7 +68,7 @@ fn main() { #[cfg(not(fuzzing))] #[derive(Debug, Parser)] -#[clap(author, version, about)] +#[command(author, version, about)] struct Opt { /// How many candidates participate in this election #[clap(short, long)] diff --git a/utils/frame/benchmarking-cli/src/pallet/mod.rs b/utils/frame/benchmarking-cli/src/pallet/mod.rs index 629a931896e0d..ae597f4054a81 100644 --- a/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -47,11 +47,11 @@ pub struct PalletCmd { pub steps: u32, /// Indicates lowest values for each of the component ranges. - #[clap(long = "low", use_value_delimiter = true)] + #[clap(long = "low", value_delimiter = ',')] pub lowest_range_values: Vec, /// Indicates highest values for each of the component ranges. - #[clap(long = "high", use_value_delimiter = true)] + #[clap(long = "high", value_delimiter = ',')] pub highest_range_values: Vec, /// Select how many repetitions of this benchmark should run from within the wasm. diff --git a/utils/frame/benchmarking-cli/src/shared/mod.rs b/utils/frame/benchmarking-cli/src/shared/mod.rs index 33189792c4008..54368d77e0669 100644 --- a/utils/frame/benchmarking-cli/src/shared/mod.rs +++ b/utils/frame/benchmarking-cli/src/shared/mod.rs @@ -95,7 +95,7 @@ pub fn check_build_profile() -> Result<(), String> { /// Parameters to configure how the host info will be determined. #[derive(Debug, Default, Serialize, Clone, PartialEq, Args)] -#[clap(rename_all = "kebab-case")] +#[command(rename_all = "kebab-case")] pub struct HostInfoParams { /// Manually override the hostname to use. #[clap(long)] diff --git a/utils/frame/frame-utilities-cli/src/pallet_id.rs b/utils/frame/frame-utilities-cli/src/pallet_id.rs index 1176c4c1c420c..9b5aa3e3bdd19 100644 --- a/utils/frame/frame-utilities-cli/src/pallet_id.rs +++ b/utils/frame/frame-utilities-cli/src/pallet_id.rs @@ -28,7 +28,7 @@ use sp_runtime::traits::AccountIdConversion; /// The `palletid` command #[derive(Debug, Parser)] -#[clap(name = "palletid", about = "Inspect a module ID address")] +#[command(name = "palletid", about = "Inspect a module ID address")] pub struct PalletIdCmd { /// The module ID used to derive the account id: String, diff --git a/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs b/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs index 5055e4fb34581..bde041888358d 100644 --- a/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs +++ b/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs @@ -31,7 +31,7 @@ use crate::{ #[derive(Debug, Clone, clap::Parser)] pub struct OnRuntimeUpgradeCmd { /// The state type to use. - #[clap(subcommand)] + #[command(subcommand)] pub state: State, } From 7342dfd134848d0e4a1532a122d5359c4a8be3e6 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Wed, 5 Oct 2022 15:06:16 +0200 Subject: [PATCH 09/20] Move remaining `clap` attributes to `arg` --- bin/node/bench/src/main.rs | 8 +-- bin/node/cli/src/cli.rs | 2 +- bin/node/inspect/src/cli.rs | 6 +- bin/utils/chain-spec-builder/src/main.rs | 20 +++--- client/cli/src/commands/build_spec_cmd.rs | 4 +- client/cli/src/commands/check_block_cmd.rs | 4 +- client/cli/src/commands/export_blocks_cmd.rs | 8 +-- client/cli/src/commands/export_state_cmd.rs | 2 +- client/cli/src/commands/generate.rs | 2 +- client/cli/src/commands/generate_node_key.rs | 4 +- client/cli/src/commands/import_blocks_cmd.rs | 6 +- client/cli/src/commands/insert_key.rs | 6 +- client/cli/src/commands/inspect_key.rs | 4 +- client/cli/src/commands/inspect_node_key.rs | 6 +- client/cli/src/commands/purge_chain_cmd.rs | 2 +- client/cli/src/commands/revert_cmd.rs | 2 +- client/cli/src/commands/run_cmd.rs | 72 +++++++++---------- client/cli/src/commands/sign.rs | 6 +- client/cli/src/commands/vanity.rs | 2 +- client/cli/src/commands/verify.rs | 4 +- client/cli/src/params/database_params.rs | 4 +- client/cli/src/params/import_params.rs | 24 +++---- client/cli/src/params/keystore_params.rs | 10 +-- client/cli/src/params/mod.rs | 6 +- client/cli/src/params/network_params.rs | 34 ++++----- client/cli/src/params/node_key_params.rs | 6 +- .../cli/src/params/offchain_worker_params.rs | 4 +- client/cli/src/params/pruning_params.rs | 4 +- client/cli/src/params/shared_params.rs | 18 ++--- .../cli/src/params/transaction_pool_params.rs | 6 +- .../npos-elections/fuzzer/src/phragmen_pjr.rs | 6 +- scripts/ci/node-template-release/src/main.rs | 4 +- .../frame/benchmarking-cli/src/block/bench.rs | 6 +- utils/frame/benchmarking-cli/src/block/cmd.rs | 2 +- .../benchmarking-cli/src/extrinsic/bench.rs | 6 +- .../benchmarking-cli/src/extrinsic/cmd.rs | 8 +-- .../frame/benchmarking-cli/src/machine/mod.rs | 12 ++-- .../benchmarking-cli/src/overhead/cmd.rs | 4 +- .../frame/benchmarking-cli/src/pallet/mod.rs | 50 ++++++------- .../frame/benchmarking-cli/src/shared/mod.rs | 6 +- .../src/shared/weight_params.rs | 8 +-- .../frame/benchmarking-cli/src/storage/cmd.rs | 22 +++--- .../frame-utilities-cli/src/pallet_id.rs | 8 +-- .../generate-bags/node-runtime/src/main.rs | 6 +- .../cli/src/commands/execute_block.rs | 12 ++-- .../cli/src/commands/follow_chain.rs | 8 +-- .../cli/src/commands/offchain_worker.rs | 8 +-- utils/frame/try-runtime/cli/src/lib.rs | 26 +++---- 48 files changed, 244 insertions(+), 244 deletions(-) diff --git a/bin/node/bench/src/main.rs b/bin/node/bench/src/main.rs index df86fe27a6623..8a5d99640eb1b 100644 --- a/bin/node/bench/src/main.rs +++ b/bin/node/bench/src/main.rs @@ -48,13 +48,13 @@ struct Opt { /// Show list of all available benchmarks. /// /// Will output ("name", "path"). Benchmarks can then be filtered by path. - #[clap(short, long)] + #[arg(short, long)] list: bool, /// Machine readable json output. /// /// This also suppresses all regular output (except to stderr) - #[clap(short, long)] + #[arg(short, long)] json: bool, /// Filter benchmarks. @@ -63,7 +63,7 @@ struct Opt { filter: Option, /// Number of transactions for block import with `custom` size. - #[clap(long)] + #[arg(long)] transactions: Option, /// Mode @@ -72,7 +72,7 @@ struct Opt { /// /// "profile" mode adds pauses between measurable runs, /// so that actual interval can be selected in the profiler of choice. - #[clap(short, long, default_value = "regular")] + #[arg(short, long, default_value = "regular")] mode: BenchmarkMode, } diff --git a/bin/node/cli/src/cli.rs b/bin/node/cli/src/cli.rs index bf830cb1e7d61..bb7f8a4c60aa9 100644 --- a/bin/node/cli/src/cli.rs +++ b/bin/node/cli/src/cli.rs @@ -34,7 +34,7 @@ pub struct Cli { /// /// The results are then printed out in the logs, and also sent as part of /// telemetry, if telemetry is enabled. - #[clap(long)] + #[arg(long)] pub no_hardware_benchmarks: bool, } diff --git a/bin/node/inspect/src/cli.rs b/bin/node/inspect/src/cli.rs index 8b7026f44736a..8769778741651 100644 --- a/bin/node/inspect/src/cli.rs +++ b/bin/node/inspect/src/cli.rs @@ -18,7 +18,7 @@ //! Structs to easily compose inspect sub-command for CLI. -use clap::{arg, command}; +use clap::arg; use sc_cli::{ImportParams, SharedParams}; /// The `inspect` command used to print decoded chain data. @@ -47,7 +47,7 @@ pub enum InspectSubCmd { /// Can be either a block hash (no 0x prefix) or a number to retrieve existing block, /// or a 0x-prefixed bytes hex string, representing SCALE encoding of /// a block. - #[clap(value_name = "HASH or NUMBER or BYTES")] + #[arg(value_name = "HASH or NUMBER or BYTES")] input: String, }, /// Decode extrinsic with native version of runtime and print out the details. @@ -57,7 +57,7 @@ pub enum InspectSubCmd { /// Can be either a block hash (no 0x prefix) or number and the index, in the form /// of `{block}:{index}` or a 0x-prefixed bytes hex string, /// representing SCALE encoding of an extrinsic. - #[clap(value_name = "BLOCK:INDEX or BYTES")] + #[arg(value_name = "BLOCK:INDEX or BYTES")] input: String, }, } diff --git a/bin/utils/chain-spec-builder/src/main.rs b/bin/utils/chain-spec-builder/src/main.rs index 56c76f2401621..f3ec4cbdf5188 100644 --- a/bin/utils/chain-spec-builder/src/main.rs +++ b/bin/utils/chain-spec-builder/src/main.rs @@ -43,45 +43,45 @@ enum ChainSpecBuilder { /// accounts. New { /// Authority key seed. - #[clap(long, short, required = true)] + #[arg(long, short, required = true)] authority_seeds: Vec, /// Active nominators (SS58 format), each backing a random subset of the aforementioned /// authorities. - #[clap(long, short, default_value = "0")] + #[arg(long, short, default_value = "0")] nominator_accounts: Vec, /// Endowed account address (SS58 format). - #[clap(long, short)] + #[arg(long, short)] endowed_accounts: Vec, /// Sudo account address (SS58 format). - #[clap(long, short)] + #[arg(long, short)] sudo_account: String, /// The path where the chain spec should be saved. - #[clap(long, short, default_value = "./chain_spec.json")] + #[arg(long, short, default_value = "./chain_spec.json")] chain_spec_path: PathBuf, }, /// Create a new chain spec with the given number of authorities and endowed /// accounts. Random keys will be generated as required. Generate { /// The number of authorities. - #[clap(long, short)] + #[arg(long, short)] authorities: usize, /// The number of nominators backing the aforementioned authorities. /// /// Will nominate a random subset of `authorities`. - #[clap(long, short, default_value = "0")] + #[arg(long, short, default_value = "0")] nominators: usize, /// The number of endowed accounts. - #[clap(long, short, default_value = "0")] + #[arg(long, short, default_value = "0")] endowed: usize, /// The path where the chain spec should be saved. - #[clap(long, short, default_value = "./chain_spec.json")] + #[arg(long, short, default_value = "./chain_spec.json")] chain_spec_path: PathBuf, /// Path to use when saving generated keystores for each authority. /// /// At this path, a new folder will be created for each authority's /// keystore named `auth-$i` where `i` is the authority index, i.e. /// `auth-0`, `auth-1`, etc. - #[clap(long, short)] + #[arg(long, short)] keystore_path: Option, }, } diff --git a/client/cli/src/commands/build_spec_cmd.rs b/client/cli/src/commands/build_spec_cmd.rs index 3196a3e7b915f..5ab3ce9e88a09 100644 --- a/client/cli/src/commands/build_spec_cmd.rs +++ b/client/cli/src/commands/build_spec_cmd.rs @@ -34,14 +34,14 @@ use std::io::Write; #[derive(Debug, Clone, Parser)] pub struct BuildSpecCmd { /// Force raw genesis storage output. - #[clap(long)] + #[arg(long)] pub raw: bool, /// Disable adding the default bootnode to the specification. /// /// By default the `/ip4/127.0.0.1/tcp/30333/p2p/NODE_PEER_ID` bootnode is added to the /// specification when no bootnode exists. - #[clap(long)] + #[arg(long)] pub disable_default_bootnode: bool, #[allow(missing_docs)] diff --git a/client/cli/src/commands/check_block_cmd.rs b/client/cli/src/commands/check_block_cmd.rs index b7e69b1360a0a..3e25eab2c4350 100644 --- a/client/cli/src/commands/check_block_cmd.rs +++ b/client/cli/src/commands/check_block_cmd.rs @@ -30,13 +30,13 @@ use std::{fmt::Debug, str::FromStr, sync::Arc}; #[derive(Debug, Clone, Parser)] pub struct CheckBlockCmd { /// Block hash or number - #[clap(value_name = "HASH or NUMBER")] + #[arg(value_name = "HASH or NUMBER")] pub input: BlockNumberOrHash, /// The default number of 64KB pages to ever allocate for Wasm execution. /// /// Don't alter this unless you know what you're doing. - #[clap(long, value_name = "COUNT")] + #[arg(long, value_name = "COUNT")] pub default_heap_pages: Option, #[allow(missing_docs)] diff --git a/client/cli/src/commands/export_blocks_cmd.rs b/client/cli/src/commands/export_blocks_cmd.rs index ba64757da3740..6cabfd57503ab 100644 --- a/client/cli/src/commands/export_blocks_cmd.rs +++ b/client/cli/src/commands/export_blocks_cmd.rs @@ -32,23 +32,23 @@ use std::{fmt::Debug, fs, io, path::PathBuf, str::FromStr, sync::Arc}; #[derive(Debug, Clone, Parser)] pub struct ExportBlocksCmd { /// Output file name or stdout if unspecified. - #[clap(value_parser)] + #[arg(value_parser)] pub output: Option, /// Specify starting block number. /// /// Default is 1. - #[clap(long, value_name = "BLOCK")] + #[arg(long, value_name = "BLOCK")] pub from: Option, /// Specify last block number. /// /// Default is best block. - #[clap(long, value_name = "BLOCK")] + #[arg(long, value_name = "BLOCK")] pub to: Option, /// Use binary output rather than JSON. - #[clap(long)] + #[arg(long)] pub binary: bool, #[allow(missing_docs)] diff --git a/client/cli/src/commands/export_state_cmd.rs b/client/cli/src/commands/export_state_cmd.rs index b76724caf0fef..63aa12213b3da 100644 --- a/client/cli/src/commands/export_state_cmd.rs +++ b/client/cli/src/commands/export_state_cmd.rs @@ -32,7 +32,7 @@ use std::{fmt::Debug, io::Write, str::FromStr, sync::Arc}; #[derive(Debug, Clone, Parser)] pub struct ExportStateCmd { /// Block hash or number. - #[clap(value_name = "HASH or NUMBER")] + #[arg(value_name = "HASH or NUMBER")] pub input: Option, #[allow(missing_docs)] diff --git a/client/cli/src/commands/generate.rs b/client/cli/src/commands/generate.rs index 46f731ebba5b0..461cb98bc2e51 100644 --- a/client/cli/src/commands/generate.rs +++ b/client/cli/src/commands/generate.rs @@ -28,7 +28,7 @@ use clap::Parser; #[command(name = "generate", about = "Generate a random account")] pub struct GenerateCmd { /// The number of words in the phrase to generate. One of 12 (default), 15, 18, 21 and 24. - #[clap(short = 'w', long, value_name = "WORDS")] + #[arg(short = 'w', long, value_name = "WORDS")] words: Option, #[allow(missing_docs)] diff --git a/client/cli/src/commands/generate_node_key.rs b/client/cli/src/commands/generate_node_key.rs index fdef154e29146..e84b4a71d6d72 100644 --- a/client/cli/src/commands/generate_node_key.rs +++ b/client/cli/src/commands/generate_node_key.rs @@ -37,13 +37,13 @@ pub struct GenerateNodeKeyCmd { /// Name of file to save secret key to. /// /// If not given, the secret key is printed to stdout. - #[clap(long)] + #[arg(long)] file: Option, /// The output is in raw binary format. /// /// If not given, the output is written as an hex encoded string. - #[clap(long)] + #[arg(long)] bin: bool, } diff --git a/client/cli/src/commands/import_blocks_cmd.rs b/client/cli/src/commands/import_blocks_cmd.rs index b56bede49e0c6..85214a27fc042 100644 --- a/client/cli/src/commands/import_blocks_cmd.rs +++ b/client/cli/src/commands/import_blocks_cmd.rs @@ -37,17 +37,17 @@ use std::{ #[derive(Debug, Parser)] pub struct ImportBlocksCmd { /// Input file or stdin if unspecified. - #[clap(value_parser)] + #[arg(value_parser)] pub input: Option, /// The default number of 64KB pages to ever allocate for Wasm execution. /// /// Don't alter this unless you know what you're doing. - #[clap(long, value_name = "COUNT")] + #[arg(long, value_name = "COUNT")] pub default_heap_pages: Option, /// Try importing blocks from binary format rather than JSON. - #[clap(long)] + #[arg(long)] pub binary: bool, #[allow(missing_docs)] diff --git a/client/cli/src/commands/insert_key.rs b/client/cli/src/commands/insert_key.rs index ca70409f2c459..7d66a680df8c0 100644 --- a/client/cli/src/commands/insert_key.rs +++ b/client/cli/src/commands/insert_key.rs @@ -34,11 +34,11 @@ pub struct InsertKeyCmd { /// The secret key URI. /// If the value is a file, the file content is used as URI. /// If not given, you will be prompted for the URI. - #[clap(long)] + #[arg(long)] suri: Option, /// Key type, examples: "gran", or "imon" - #[clap(long)] + #[arg(long)] key_type: String, #[allow(missing_docs)] @@ -50,7 +50,7 @@ pub struct InsertKeyCmd { pub keystore_params: KeystoreParams, /// The cryptography scheme that should be used to generate the key out of the given URI. - #[clap(long, value_name = "SCHEME", value_enum, ignore_case = true)] + #[arg(long, value_name = "SCHEME", value_enum, ignore_case = true)] pub scheme: CryptoScheme, } diff --git a/client/cli/src/commands/inspect_key.rs b/client/cli/src/commands/inspect_key.rs index f7193745e0eb1..369fd10926dce 100644 --- a/client/cli/src/commands/inspect_key.rs +++ b/client/cli/src/commands/inspect_key.rs @@ -44,7 +44,7 @@ pub struct InspectKeyCmd { uri: Option, /// Is the given `uri` a hex encoded public key? - #[clap(long)] + #[arg(long)] public: bool, #[allow(missing_docs)] @@ -72,7 +72,7 @@ pub struct InspectKeyCmd { /// /// If there is no derivation in `--uri`, the public key will be checked against the public key /// of `--uri` directly. - #[clap(long, conflicts_with = "public")] + #[arg(long, conflicts_with = "public")] pub expect_public: Option, } diff --git a/client/cli/src/commands/inspect_node_key.rs b/client/cli/src/commands/inspect_node_key.rs index a83c1a98362a8..9300007cb6bf2 100644 --- a/client/cli/src/commands/inspect_node_key.rs +++ b/client/cli/src/commands/inspect_node_key.rs @@ -36,18 +36,18 @@ pub struct InspectNodeKeyCmd { /// Name of file to read the secret key from. /// /// If not given, the secret key is read from stdin (up to EOF). - #[clap(long)] + #[arg(long)] file: Option, /// The input is in raw binary format. /// /// If not given, the input is read as an hex encoded string. - #[clap(long)] + #[arg(long)] bin: bool, /// This argument is deprecated and has no effect for this command. #[deprecated(note = "Network identifier is not used for node-key inspection")] - #[clap(short = 'n', long = "network", value_name = "NETWORK", ignore_case = true)] + #[arg(short = 'n', long = "network", value_name = "NETWORK", ignore_case = true)] pub network_scheme: Option, } diff --git a/client/cli/src/commands/purge_chain_cmd.rs b/client/cli/src/commands/purge_chain_cmd.rs index b89487a18f779..9a3aeee50e944 100644 --- a/client/cli/src/commands/purge_chain_cmd.rs +++ b/client/cli/src/commands/purge_chain_cmd.rs @@ -33,7 +33,7 @@ use std::{ #[derive(Debug, Clone, Parser)] pub struct PurgeChainCmd { /// Skip interactive prompt by answering yes automatically. - #[clap(short = 'y')] + #[arg(short = 'y')] pub yes: bool, #[allow(missing_docs)] diff --git a/client/cli/src/commands/revert_cmd.rs b/client/cli/src/commands/revert_cmd.rs index f65e348b37b89..8477630cf9404 100644 --- a/client/cli/src/commands/revert_cmd.rs +++ b/client/cli/src/commands/revert_cmd.rs @@ -31,7 +31,7 @@ use std::{fmt::Debug, str::FromStr, sync::Arc}; #[derive(Debug, Parser)] pub struct RevertCmd { /// Number of blocks to revert. - #[clap(default_value = "256")] + #[arg(default_value = "256")] pub num: GenericNumber, #[allow(missing_docs)] diff --git a/client/cli/src/commands/run_cmd.rs b/client/cli/src/commands/run_cmd.rs index f4ade909d3b5a..36e70e8530e90 100644 --- a/client/cli/src/commands/run_cmd.rs +++ b/client/cli/src/commands/run_cmd.rs @@ -42,12 +42,12 @@ pub struct RunCmd { /// The node will be started with the authority role and actively /// participate in any consensus task that it can (e.g. depending on /// availability of local keys). - #[clap(long)] + #[arg(long)] pub validator: bool, /// Disable GRANDPA voter when running in validator mode, otherwise disable the GRANDPA /// observer. - #[clap(long)] + #[arg(long)] pub no_grandpa: bool, /// Listen to all RPC interfaces. @@ -56,13 +56,13 @@ pub struct RunCmd { /// proxy server to filter out dangerous methods. More details: /// . /// Use `--unsafe-rpc-external` to suppress the warning if you understand the risks. - #[clap(long)] + #[arg(long)] pub rpc_external: bool, /// Listen to all RPC interfaces. /// /// Same as `--rpc-external`. - #[clap(long)] + #[arg(long)] pub unsafe_rpc_external: bool, /// RPC methods to expose. @@ -71,7 +71,7 @@ pub struct RunCmd { /// - `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 /// passed, otherwise acts as `unsafe`. - #[clap( + #[arg( long, value_name = "METHOD SET", value_enum, @@ -87,59 +87,59 @@ pub struct RunCmd { /// proxy server to filter out dangerous methods. More details: /// . /// Use `--unsafe-ws-external` to suppress the warning if you understand the risks. - #[clap(long)] + #[arg(long)] pub ws_external: bool, /// Listen to all Websocket interfaces. /// /// Same as `--ws-external` but doesn't warn you about it. - #[clap(long)] + #[arg(long)] pub unsafe_ws_external: bool, /// DEPRECATED, this has no affect anymore. Use `rpc_max_request_size` or /// `rpc_max_response_size` instead. - #[clap(long)] + #[arg(long)] pub rpc_max_payload: Option, /// Set the the maximum RPC request payload size for both HTTP and WS in megabytes. /// Default is 15MiB. - #[clap(long)] + #[arg(long)] pub rpc_max_request_size: Option, /// Set the the maximum RPC response payload size for both HTTP and WS in megabytes. /// Default is 15MiB. - #[clap(long)] + #[arg(long)] pub rpc_max_response_size: Option, /// Set the the maximum concurrent subscriptions per connection. /// Default is 1024. - #[clap(long)] + #[arg(long)] pub rpc_max_subscriptions_per_connection: Option, /// Expose Prometheus exporter on all interfaces. /// /// Default is local. - #[clap(long)] + #[arg(long)] pub prometheus_external: bool, /// DEPRECATED, IPC support has been removed. - #[clap(long, value_name = "PATH")] + #[arg(long, value_name = "PATH")] pub ipc_path: Option, /// Specify HTTP RPC server TCP port. - #[clap(long, value_name = "PORT")] + #[arg(long, value_name = "PORT")] pub rpc_port: Option, /// Specify WebSockets RPC server TCP port. - #[clap(long, value_name = "PORT")] + #[arg(long, value_name = "PORT")] pub ws_port: Option, /// Maximum number of WS RPC server connections. - #[clap(long, value_name = "COUNT")] + #[arg(long, value_name = "COUNT")] pub ws_max_connections: Option, /// DEPRECATED, this has no affect anymore. Use `rpc_max_response_size` instead. - #[clap(long)] + #[arg(long)] pub ws_max_out_buffer_capacity: Option, /// Specify browser Origins allowed to access the HTTP & WS RPC servers. @@ -148,29 +148,29 @@ pub struct RunCmd { /// value). Value of `all` will disable origin validation. Default is to /// allow localhost and origins. When running in /// --dev mode the default is to allow all origins. - #[clap(long, value_name = "ORIGINS", value_parser = parse_cors)] + #[arg(long, value_name = "ORIGINS", value_parser = parse_cors)] pub rpc_cors: Option, /// Specify Prometheus exporter TCP Port. - #[clap(long, value_name = "PORT")] + #[arg(long, value_name = "PORT")] pub prometheus_port: Option, /// Do not expose a Prometheus exporter endpoint. /// /// Prometheus metric endpoint is enabled by default. - #[clap(long)] + #[arg(long)] pub no_prometheus: bool, /// The human-readable name for this node. /// /// The node name will be reported to the telemetry server, if enabled. - #[clap(long, value_name = "NAME")] + #[arg(long, value_name = "NAME")] pub name: Option, /// Disable connecting to the Substrate telemetry server. /// /// Telemetry is on by default on global chains. - #[clap(long)] + #[arg(long)] pub no_telemetry: bool, /// The URL of the telemetry server to connect to. @@ -179,7 +179,7 @@ pub struct RunCmd { /// telemetry endpoints. Verbosity levels range from 0-9, with 0 denoting /// the least verbosity. /// Expected format is 'URL VERBOSITY', e.g. `--telemetry-url 'wss://foo/bar 0'`. - #[clap(long = "telemetry-url", value_name = "URL VERBOSITY", value_parser = parse_telemetry_endpoints)] + #[arg(long = "telemetry-url", value_name = "URL VERBOSITY", value_parser = parse_telemetry_endpoints)] pub telemetry_endpoints: Vec<(String, u8)>, #[allow(missing_docs)] @@ -203,40 +203,40 @@ pub struct RunCmd { pub pool_config: TransactionPoolParams, /// Shortcut for `--name Alice --validator` with session keys for `Alice` added to keystore. - #[clap(long, conflicts_with_all = &["bob", "charlie", "dave", "eve", "ferdie", "one", "two"])] + #[arg(long, conflicts_with_all = &["bob", "charlie", "dave", "eve", "ferdie", "one", "two"])] pub alice: bool, /// Shortcut for `--name Bob --validator` with session keys for `Bob` added to keystore. - #[clap(long, conflicts_with_all = &["alice", "charlie", "dave", "eve", "ferdie", "one", "two"])] + #[arg(long, conflicts_with_all = &["alice", "charlie", "dave", "eve", "ferdie", "one", "two"])] pub bob: bool, /// Shortcut for `--name Charlie --validator` with session keys for `Charlie` added to /// keystore. - #[clap(long, conflicts_with_all = &["alice", "bob", "dave", "eve", "ferdie", "one", "two"])] + #[arg(long, conflicts_with_all = &["alice", "bob", "dave", "eve", "ferdie", "one", "two"])] pub charlie: bool, /// Shortcut for `--name Dave --validator` with session keys for `Dave` added to keystore. - #[clap(long, conflicts_with_all = &["alice", "bob", "charlie", "eve", "ferdie", "one", "two"])] + #[arg(long, conflicts_with_all = &["alice", "bob", "charlie", "eve", "ferdie", "one", "two"])] pub dave: bool, /// Shortcut for `--name Eve --validator` with session keys for `Eve` added to keystore. - #[clap(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "ferdie", "one", "two"])] + #[arg(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "ferdie", "one", "two"])] pub eve: bool, /// Shortcut for `--name Ferdie --validator` with session keys for `Ferdie` added to keystore. - #[clap(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "one", "two"])] + #[arg(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "one", "two"])] pub ferdie: bool, /// Shortcut for `--name One --validator` with session keys for `One` added to keystore. - #[clap(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "ferdie", "two"])] + #[arg(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "ferdie", "two"])] pub one: bool, /// Shortcut for `--name Two --validator` with session keys for `Two` added to keystore. - #[clap(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "ferdie", "one"])] + #[arg(long, conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "ferdie", "one"])] pub two: bool, /// Enable authoring even when offline. - #[clap(long)] + #[arg(long)] pub force_authoring: bool, #[allow(missing_docs)] @@ -246,11 +246,11 @@ pub struct RunCmd { /// The size of the instances cache for each runtime. /// /// The default value is 8 and the values higher than 256 are ignored. - #[clap(long)] + #[arg(long)] pub max_runtime_instances: Option, /// Maximum number of different runtimes that can be cached. - #[clap(long, default_value = "2")] + #[arg(long, default_value = "2")] pub runtime_cache_size: u8, /// Run a temporary node. @@ -262,7 +262,7 @@ pub struct RunCmd { /// which includes: database, node key and keystore. /// /// When `--dev` is given and no explicit `--base-path`, this option is implied. - #[clap(long, conflicts_with = "base_path")] + #[arg(long, conflicts_with = "base_path")] pub tmp: bool, } @@ -597,7 +597,7 @@ impl From for Option> { } /// Parse cors origins. -fn parse_cors(s: &str) -> std::result::Result { +fn parse_cors(s: &str) -> Result { let mut is_all = false; let mut origins = Vec::new(); for part in s.split(',') { diff --git a/client/cli/src/commands/sign.rs b/client/cli/src/commands/sign.rs index 33fecc46bdb0b..2c3ff3a1575fd 100644 --- a/client/cli/src/commands/sign.rs +++ b/client/cli/src/commands/sign.rs @@ -28,16 +28,16 @@ pub struct SignCmd { /// The secret key URI. /// If the value is a file, the file content is used as URI. /// If not given, you will be prompted for the URI. - #[clap(long)] + #[arg(long)] suri: Option, /// Message to sign, if not provided you will be prompted to /// pass the message via STDIN - #[clap(long)] + #[arg(long)] message: Option, /// The message on STDIN is hex-encoded data - #[clap(long)] + #[arg(long)] hex: bool, #[allow(missing_docs)] diff --git a/client/cli/src/commands/vanity.rs b/client/cli/src/commands/vanity.rs index bb4cec1d770d4..ae0007ac7964d 100644 --- a/client/cli/src/commands/vanity.rs +++ b/client/cli/src/commands/vanity.rs @@ -32,7 +32,7 @@ use utils::print_from_uri; #[command(name = "vanity", about = "Generate a seed that provides a vanity address")] pub struct VanityCmd { /// Desired pattern - #[clap(long, value_parser = assert_non_empty_string)] + #[arg(long, value_parser = assert_non_empty_string)] pattern: String, #[allow(missing_docs)] diff --git a/client/cli/src/commands/verify.rs b/client/cli/src/commands/verify.rs index 2877a94400f95..82554fbf268fa 100644 --- a/client/cli/src/commands/verify.rs +++ b/client/cli/src/commands/verify.rs @@ -39,11 +39,11 @@ pub struct VerifyCmd { /// Message to verify, if not provided you will be prompted to /// pass the message via STDIN - #[clap(long)] + #[arg(long)] message: Option, /// The message on STDIN is hex-encoded data - #[clap(long)] + #[arg(long)] hex: bool, #[allow(missing_docs)] diff --git a/client/cli/src/params/database_params.rs b/client/cli/src/params/database_params.rs index 277b68f4f908a..3c9ae09e9ab42 100644 --- a/client/cli/src/params/database_params.rs +++ b/client/cli/src/params/database_params.rs @@ -23,11 +23,11 @@ use clap::Args; #[derive(Debug, Clone, PartialEq, Args)] pub struct DatabaseParams { /// Select database backend to use. - #[clap(long, alias = "db", value_name = "DB", value_enum)] + #[arg(long, alias = "db", value_name = "DB", value_enum)] pub database: Option, /// Limit the memory the database cache can use. - #[clap(long = "db-cache", value_name = "MiB")] + #[arg(long = "db-cache", value_name = "MiB")] pub database_cache_size: Option, } diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs index e8264384ef6b4..74728fd3cfc06 100644 --- a/client/cli/src/params/import_params.rs +++ b/client/cli/src/params/import_params.rs @@ -49,12 +49,12 @@ pub struct ImportParams { /// up error. /// /// Details: - #[clap(long)] + #[arg(long)] #[deprecated = "According to https://github.com/paritytech/substrate/issues/8103"] pub unsafe_pruning: bool, /// Method for executing Wasm runtime code. - #[clap( + #[arg( long = "wasm-execution", value_name = "METHOD", value_enum, @@ -76,7 +76,7 @@ pub struct ImportParams { /// The `legacy-instance-reuse` strategy is deprecated and will /// be removed in the future. It should only be used in case of /// issues with the default instantiation strategy. - #[clap( + #[arg( long, value_name = "STRATEGY", default_value_t = DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, @@ -87,7 +87,7 @@ pub struct ImportParams { /// Specify the path where local WASM runtimes are stored. /// /// These runtimes will override on-chain runtimes when the version matches. - #[clap(long, value_name = "PATH", value_parser)] + #[arg(long, value_name = "PATH", value_parser)] pub wasm_runtime_overrides: Option, #[allow(missing_docs)] @@ -97,13 +97,13 @@ pub struct ImportParams { /// Specify the state cache size. /// /// Providing `0` will disable the cache. - #[clap(long, value_name = "Bytes", default_value = "67108864")] + #[arg(long, value_name = "Bytes", default_value = "67108864")] pub trie_cache_size: usize, /// DEPRECATED /// /// Switch to `--trie-cache-size`. - #[clap(long)] + #[arg(long)] state_cache_size: Option, } @@ -168,29 +168,29 @@ impl ImportParams { pub struct ExecutionStrategiesParams { /// The means of execution used when calling into the runtime for importing blocks as /// part of an initial sync. - #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] + #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution_syncing: Option, /// The means of execution used when calling into the runtime for general block import /// (including locally authored blocks). - #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] + #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution_import_block: Option, /// The means of execution used when calling into the runtime while constructing blocks. - #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] + #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution_block_construction: Option, /// The means of execution used when calling into the runtime while using an off-chain worker. - #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] + #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution_offchain_worker: Option, /// The means of execution used when calling into the runtime while not syncing, importing or /// constructing blocks. - #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] + #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution_other: Option, /// The execution strategy that should be used by all execution contexts. - #[clap( + #[arg( long, value_name = "STRATEGY", value_enum, diff --git a/client/cli/src/params/keystore_params.rs b/client/cli/src/params/keystore_params.rs index a53643aa1490d..23a20051b82b3 100644 --- a/client/cli/src/params/keystore_params.rs +++ b/client/cli/src/params/keystore_params.rs @@ -32,20 +32,20 @@ const DEFAULT_KEYSTORE_CONFIG_PATH: &str = "keystore"; #[derive(Debug, Clone, Args)] pub struct KeystoreParams { /// Specify custom URIs to connect to for keystore-services - #[clap(long)] + #[arg(long)] pub keystore_uri: Option, /// Specify custom keystore path. - #[clap(long, value_name = "PATH", value_parser)] + #[arg(long, value_name = "PATH", value_parser)] pub keystore_path: Option, /// Use interactive shell for entering the password used by the keystore. - #[clap(long, conflicts_with_all = &["password", "password_filename"])] + #[arg(long, conflicts_with_all = &["password", "password_filename"])] pub password_interactive: bool, /// Password used by the keystore. This allows appending an extra user-defined secret to the /// seed. - #[clap( + #[arg( long, value_parser = secret_string_from_str, conflicts_with_all = &["password_interactive", "password_filename"] @@ -53,7 +53,7 @@ pub struct KeystoreParams { pub password: Option, /// File that contains the password used by the keystore. - #[clap( + #[arg( long, value_name = "PATH", value_parser, diff --git a/client/cli/src/params/mod.rs b/client/cli/src/params/mod.rs index 9df8ada11e1cd..6afaae28b5b87 100644 --- a/client/cli/src/params/mod.rs +++ b/client/cli/src/params/mod.rs @@ -132,7 +132,7 @@ impl BlockNumberOrHash { #[derive(Debug, Clone, Args)] pub struct CryptoSchemeFlag { /// cryptography scheme - #[clap(long, value_name = "SCHEME", value_enum, ignore_case = true, default_value = "sr25519")] + #[arg(long, value_name = "SCHEME", value_enum, ignore_case = true, default_value = "sr25519")] pub scheme: CryptoScheme, } @@ -140,7 +140,7 @@ pub struct CryptoSchemeFlag { #[derive(Debug, Clone, Args)] pub struct OutputTypeFlag { /// output format - #[clap(long, value_name = "FORMAT", value_enum, ignore_case = true, default_value = "text")] + #[arg(long, value_name = "FORMAT", value_enum, ignore_case = true, default_value = "text")] pub output_type: OutputType, } @@ -148,7 +148,7 @@ pub struct OutputTypeFlag { #[derive(Debug, Clone, Args)] pub struct NetworkSchemeFlag { /// network address format - #[clap( + #[arg( short = 'n', long, value_name = "NETWORK", diff --git a/client/cli/src/params/network_params.rs b/client/cli/src/params/network_params.rs index 2abed2dd3df25..0a9e1450ee81c 100644 --- a/client/cli/src/params/network_params.rs +++ b/client/cli/src/params/network_params.rs @@ -33,11 +33,11 @@ use std::{borrow::Cow, path::PathBuf}; #[derive(Debug, Clone, Args)] pub struct NetworkParams { /// Specify a list of bootnodes. - #[clap(long, value_name = "ADDR", num_args = 0..)] + #[arg(long, value_name = "ADDR", num_args = 0..)] pub bootnodes: Vec, /// Specify a list of reserved node addresses. - #[clap(long, value_name = "ADDR", num_args = 0..)] + #[arg(long, value_name = "ADDR", num_args = 0..)] pub reserved_nodes: Vec, /// Whether to only synchronize the chain with reserved nodes. @@ -48,12 +48,12 @@ pub struct NetworkParams { /// In particular, if you are a validator your node might still connect to other /// validator nodes and collator nodes regardless of whether they are defined as /// reserved nodes. - #[clap(long)] + #[arg(long)] pub reserved_only: bool, /// The public address that other nodes will use to connect to it. /// This can be used if there's a proxy in front of this node. - #[clap(long, value_name = "PUBLIC_ADDR", num_args = 0..)] + #[arg(long, value_name = "PUBLIC_ADDR", num_args = 0..)] pub public_addr: Vec, /// Listen on this multiaddress. @@ -61,49 +61,49 @@ pub struct NetworkParams { /// By default: /// If `--validator` is passed: `/ip4/0.0.0.0/tcp/` and `/ip6/[::]/tcp/`. /// Otherwise: `/ip4/0.0.0.0/tcp//ws` and `/ip6/[::]/tcp//ws`. - #[clap(long, value_name = "LISTEN_ADDR", num_args = 0..)] + #[arg(long, value_name = "LISTEN_ADDR", num_args = 0..)] pub listen_addr: Vec, /// Specify p2p protocol TCP port. - #[clap(long, value_name = "PORT", conflicts_with_all = &[ "listen_addr" ])] + #[arg(long, value_name = "PORT", conflicts_with_all = &[ "listen_addr" ])] pub port: Option, /// Always forbid connecting to private IPv4 addresses (as specified in /// [RFC1918](https://tools.ietf.org/html/rfc1918)), unless the address was passed with /// `--reserved-nodes` or `--bootnodes`. Enabled by default for chains marked as "live" in /// their chain specifications. - #[clap(long, conflicts_with_all = &["allow_private_ipv4"])] + #[arg(long, conflicts_with_all = &["allow_private_ipv4"])] pub no_private_ipv4: bool, /// Always accept connecting to private IPv4 addresses (as specified in /// [RFC1918](https://tools.ietf.org/html/rfc1918)). Enabled by default for chains marked as /// "local" in their chain specifications, or when `--dev` is passed. - #[clap(long, conflicts_with_all = &["no_private_ipv4"])] + #[arg(long, conflicts_with_all = &["no_private_ipv4"])] pub allow_private_ipv4: bool, /// Specify the number of outgoing connections we're trying to maintain. - #[clap(long, value_name = "COUNT", default_value = "25")] + #[arg(long, value_name = "COUNT", default_value = "25")] pub out_peers: u32, /// Maximum number of inbound full nodes peers. - #[clap(long, value_name = "COUNT", default_value = "25")] + #[arg(long, value_name = "COUNT", default_value = "25")] pub in_peers: u32, /// Maximum number of inbound light nodes peers. - #[clap(long, value_name = "COUNT", default_value = "100")] + #[arg(long, value_name = "COUNT", default_value = "100")] pub in_peers_light: u32, /// Disable mDNS discovery. /// /// By default, the network will use mDNS to discover other nodes on the /// local network. This disables it. Automatically implied when using --dev. - #[clap(long)] + #[arg(long)] pub no_mdns: bool, /// Maximum number of peers from which to ask for the same blocks in parallel. /// /// This allows downloading announced blocks from multiple peers. Decrease to save /// traffic and risk increased latency. - #[clap(long, value_name = "COUNT", default_value = "5")] + #[arg(long, value_name = "COUNT", default_value = "5")] pub max_parallel_downloads: u32, #[allow(missing_docs)] @@ -114,7 +114,7 @@ pub struct NetworkParams { /// /// By default this option is `true` for `--dev` or when the chain type is /// `Local`/`Development` and false otherwise. - #[clap(long)] + #[arg(long)] pub discover_local: bool, /// Require iterative Kademlia DHT queries to use disjoint paths for increased resiliency in @@ -122,11 +122,11 @@ pub struct NetworkParams { /// /// See the S/Kademlia paper for more information on the high level design as well as its /// security improvements. - #[clap(long)] + #[arg(long)] pub kademlia_disjoint_query_paths: bool, /// Join the IPFS network and serve transactions over bitswap protocol. - #[clap(long)] + #[arg(long)] pub ipfs_server: bool, /// Blockchain syncing mode. @@ -135,7 +135,7 @@ pub struct NetworkParams { /// - `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. - #[clap( + #[arg( long, value_enum, value_name = "SYNC_MODE", diff --git a/client/cli/src/params/node_key_params.rs b/client/cli/src/params/node_key_params.rs index 5d42ab80b0429..e7e2f31f1b1ff 100644 --- a/client/cli/src/params/node_key_params.rs +++ b/client/cli/src/params/node_key_params.rs @@ -46,7 +46,7 @@ pub struct NodeKeyParams { /// WARNING: Secrets provided as command-line arguments are easily exposed. /// Use of this option should be limited to development and testing. To use /// an externally managed secret key, use `--node-key-file` instead. - #[clap(long, value_name = "KEY")] + #[arg(long, value_name = "KEY")] pub node_key: Option, /// The type of secret key to use for libp2p networking. @@ -66,7 +66,7 @@ pub struct NodeKeyParams { /// /// The node's secret key determines the corresponding public key and hence the /// node's peer ID in the context of libp2p. - #[clap(long, value_name = "TYPE", value_enum, ignore_case = true, default_value = "ed25519")] + #[arg(long, value_name = "TYPE", value_enum, ignore_case = true, default_value = "ed25519")] pub node_key_type: NodeKeyType, /// The file from which to read the node's secret key to use for libp2p networking. @@ -79,7 +79,7 @@ pub struct NodeKeyParams { /// /// If the file does not exist, it is created with a newly generated secret key of /// the chosen type. - #[clap(long, value_name = "FILE")] + #[arg(long, value_name = "FILE")] pub node_key_file: Option, } diff --git a/client/cli/src/params/offchain_worker_params.rs b/client/cli/src/params/offchain_worker_params.rs index 346a0051ea1b9..be92fa4004cff 100644 --- a/client/cli/src/params/offchain_worker_params.rs +++ b/client/cli/src/params/offchain_worker_params.rs @@ -35,7 +35,7 @@ pub struct OffchainWorkerParams { /// Should execute offchain workers on every block. /// /// By default it's only enabled for nodes that are authoring new blocks. - #[clap( + #[arg( long = "offchain-worker", value_name = "ENABLED", value_enum, @@ -48,7 +48,7 @@ pub struct OffchainWorkerParams { /// /// Enables a runtime to write directly to a offchain workers /// DB during block import. - #[clap(long = "enable-offchain-indexing", value_name = "ENABLE_OFFCHAIN_INDEXING")] + #[arg(long = "enable-offchain-indexing", value_name = "ENABLE_OFFCHAIN_INDEXING")] pub indexing_enabled: bool, } diff --git a/client/cli/src/params/pruning_params.rs b/client/cli/src/params/pruning_params.rs index b764e4722e94d..2da1de919771c 100644 --- a/client/cli/src/params/pruning_params.rs +++ b/client/cli/src/params/pruning_params.rs @@ -28,7 +28,7 @@ pub struct PruningParams { /// Default is to keep only the last 256 blocks, /// otherwise, the state can be kept for all of the blocks (i.e 'archive'), /// or for all of the canonical blocks (i.e 'archive-canonical'). - #[clap(alias = "pruning", long, value_name = "PRUNING_MODE")] + #[arg(alias = "pruning", long, value_name = "PRUNING_MODE")] pub state_pruning: Option, /// Specify the blocks pruning mode, a number of blocks to keep or 'archive'. /// @@ -38,7 +38,7 @@ pub struct PruningParams { /// or for the last N blocks (i.e a number). /// /// NOTE: only finalized blocks are subject for removal! - #[clap(alias = "keep-blocks", long, value_name = "COUNT")] + #[arg(alias = "keep-blocks", long, value_name = "COUNT")] pub blocks_pruning: Option, } diff --git a/client/cli/src/params/shared_params.rs b/client/cli/src/params/shared_params.rs index 7e37d7597bc72..52937cefbbffb 100644 --- a/client/cli/src/params/shared_params.rs +++ b/client/cli/src/params/shared_params.rs @@ -28,25 +28,25 @@ pub struct SharedParams { /// /// It can be one of the predefined ones (dev, local, or staging) or it can be a path to a file /// with the chainspec (such as one exported by the `build-spec` subcommand). - #[clap(long, value_name = "CHAIN_SPEC")] + #[arg(long, value_name = "CHAIN_SPEC")] pub chain: Option, /// Specify the development chain. /// /// This flag sets `--chain=dev`, `--force-authoring`, `--rpc-cors=all`, /// `--alice`, and `--tmp` flags, unless explicitly overridden. - #[clap(long, conflicts_with_all = &["chain"])] + #[arg(long, conflicts_with_all = &["chain"])] pub dev: bool, /// Specify custom base path. - #[clap(long, short = 'd', value_name = "PATH", value_parser)] + #[arg(long, short = 'd', value_name = "PATH", value_parser)] pub base_path: Option, /// Sets a custom logging filter. Syntax is =, e.g. -lsync=debug. /// /// Log levels (least to most verbose) are error, warn, info, debug, and trace. /// By default, all targets log `info`. The global log level can be set with -l. - #[clap(short = 'l', long, value_name = "LOG_PATTERN", num_args = 0..)] + #[arg(short = 'l', long, value_name = "LOG_PATTERN", num_args = 0..)] pub log: Vec, /// Enable detailed log output. @@ -54,11 +54,11 @@ pub struct SharedParams { /// This includes displaying the log target, log level and thread name. /// /// This is automatically enabled when something is logged with any higher level than `info`. - #[clap(long)] + #[arg(long)] pub detailed_log_output: bool, /// Disable log color output. - #[clap(long)] + #[arg(long)] pub disable_log_color: bool, /// Enable feature to dynamically update and reload the log filter. @@ -68,15 +68,15 @@ pub struct SharedParams { /// /// The `system_addLogFilter` and `system_resetLogFilter` RPCs will have no effect with this /// option not being set. - #[clap(long)] + #[arg(long)] pub enable_log_reloading: bool, /// Sets a custom profiling filter. Syntax is the same as for logging: = - #[clap(long, value_name = "TARGETS")] + #[arg(long, value_name = "TARGETS")] pub tracing_targets: Option, /// Receiver to process tracing messages. - #[clap(long, value_name = "RECEIVER", value_enum, ignore_case = true, default_value = "log")] + #[arg(long, value_name = "RECEIVER", value_enum, ignore_case = true, default_value = "log")] pub tracing_receiver: TracingReceiver, } diff --git a/client/cli/src/params/transaction_pool_params.rs b/client/cli/src/params/transaction_pool_params.rs index 6429dfec3f908..ed03533aedbb6 100644 --- a/client/cli/src/params/transaction_pool_params.rs +++ b/client/cli/src/params/transaction_pool_params.rs @@ -23,15 +23,15 @@ use sc_service::config::TransactionPoolOptions; #[derive(Debug, Clone, Args)] pub struct TransactionPoolParams { /// Maximum number of transactions in the transaction pool. - #[clap(long, value_name = "COUNT", default_value = "8192")] + #[arg(long, value_name = "COUNT", default_value = "8192")] pub pool_limit: usize, /// Maximum number of kilobytes of all transactions stored in the pool. - #[clap(long, value_name = "COUNT", default_value = "20480")] + #[arg(long, value_name = "COUNT", default_value = "20480")] pub pool_kbytes: usize, /// How long a transaction is banned for, if it is considered invalid. Defaults to 1800s. - #[clap(long, value_name = "SECONDS")] + #[arg(long, value_name = "SECONDS")] pub tx_ban_seconds: Option, } diff --git a/primitives/npos-elections/fuzzer/src/phragmen_pjr.rs b/primitives/npos-elections/fuzzer/src/phragmen_pjr.rs index af2b6a36819df..0401249a3df1d 100644 --- a/primitives/npos-elections/fuzzer/src/phragmen_pjr.rs +++ b/primitives/npos-elections/fuzzer/src/phragmen_pjr.rs @@ -71,15 +71,15 @@ fn main() { #[command(author, version, about)] struct Opt { /// How many candidates participate in this election - #[clap(short, long)] + #[arg(short, long)] candidates: Option, /// How many voters participate in this election - #[clap(short, long)] + #[arg(short, long)] voters: Option, /// Random seed to use in this election - #[clap(long)] + #[arg(long)] seed: Option, } diff --git a/scripts/ci/node-template-release/src/main.rs b/scripts/ci/node-template-release/src/main.rs index 6c47f3cdcc701..20ac44148feff 100644 --- a/scripts/ci/node-template-release/src/main.rs +++ b/scripts/ci/node-template-release/src/main.rs @@ -29,10 +29,10 @@ type CargoToml = HashMap; #[derive(Parser)] struct Options { /// The path to the `node-template` source. - #[clap(value_parser)] + #[arg(value_parser)] node_template: PathBuf, /// The path where to output the generated `tar.gz` file. - #[clap(value_parser)] + #[arg(value_parser)] output: PathBuf, } diff --git a/utils/frame/benchmarking-cli/src/block/bench.rs b/utils/frame/benchmarking-cli/src/block/bench.rs index 32282b314b804..f3f85967153c5 100644 --- a/utils/frame/benchmarking-cli/src/block/bench.rs +++ b/utils/frame/benchmarking-cli/src/block/bench.rs @@ -43,15 +43,15 @@ const LOG_TARGET: &'static str = "benchmark::block::weight"; #[derive(Debug, Default, Serialize, Clone, PartialEq, Args)] pub struct BenchmarkParams { /// Number of the first block to consider. - #[clap(long)] + #[arg(long)] pub from: u32, /// Last block number to consider. - #[clap(long)] + #[arg(long)] pub to: u32, /// Number of times that the benchmark should be repeated for each block. - #[clap(long, default_value = "10")] + #[arg(long, default_value = "10")] pub repeat: u32, } diff --git a/utils/frame/benchmarking-cli/src/block/cmd.rs b/utils/frame/benchmarking-cli/src/block/cmd.rs index 14cbb1b438686..f5f7e15a316b3 100644 --- a/utils/frame/benchmarking-cli/src/block/cmd.rs +++ b/utils/frame/benchmarking-cli/src/block/cmd.rs @@ -71,7 +71,7 @@ pub struct BlockCmd { /// Enable the Trie cache. /// /// This should only be used for performance analysis and not for final results. - #[clap(long)] + #[arg(long)] pub enable_trie_cache: bool, } diff --git a/utils/frame/benchmarking-cli/src/extrinsic/bench.rs b/utils/frame/benchmarking-cli/src/extrinsic/bench.rs index 5dcf05956d42c..444b67ae2c5ed 100644 --- a/utils/frame/benchmarking-cli/src/extrinsic/bench.rs +++ b/utils/frame/benchmarking-cli/src/extrinsic/bench.rs @@ -43,17 +43,17 @@ use crate::shared::{StatSelect, Stats}; #[derive(Debug, Default, Serialize, Clone, PartialEq, Args)] pub struct BenchmarkParams { /// Rounds of warmups before measuring. - #[clap(long, default_value = "10")] + #[arg(long, default_value = "10")] pub warmup: u32, /// How many times the benchmark should be repeated. - #[clap(long, default_value = "100")] + #[arg(long, default_value = "100")] pub repeat: u32, /// Maximal number of extrinsics that should be put into a block. /// /// Only useful for debugging. - #[clap(long)] + #[arg(long)] pub max_ext_per_block: Option, } diff --git a/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs b/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs index 339d6126bcd09..b95cd6b5c2e42 100644 --- a/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs +++ b/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs @@ -62,21 +62,21 @@ pub struct ExtrinsicParams { /// List all available pallets and extrinsics. /// /// The format is CSV with header `pallet, extrinsic`. - #[clap(long)] + #[arg(long)] pub list: bool, /// Pallet name of the extrinsic to benchmark. - #[clap(long, value_name = "PALLET", required_unless_present = "list")] + #[arg(long, value_name = "PALLET", required_unless_present = "list")] pub pallet: Option, /// Extrinsic to benchmark. - #[clap(long, value_name = "EXTRINSIC", required_unless_present = "list")] + #[arg(long, value_name = "EXTRINSIC", required_unless_present = "list")] pub extrinsic: Option, /// Enable the Trie cache. /// /// This should only be used for performance analysis and not for final results. - #[clap(long)] + #[arg(long)] pub enable_trie_cache: bool, } diff --git a/utils/frame/benchmarking-cli/src/machine/mod.rs b/utils/frame/benchmarking-cli/src/machine/mod.rs index 5f27c71983905..0a23be21bfabc 100644 --- a/utils/frame/benchmarking-cli/src/machine/mod.rs +++ b/utils/frame/benchmarking-cli/src/machine/mod.rs @@ -53,30 +53,30 @@ pub struct MachineCmd { /// Do not return an error if any check fails. /// /// Should only be used for debugging. - #[clap(long)] + #[arg(long)] pub allow_fail: bool, /// Set a fault tolerance for passing a requirement. /// /// 10% means that the test would pass even when only 90% score was archived. /// Can be used to mitigate outliers of the benchmarks. - #[clap(long, default_value = "10.0", value_name = "PERCENT")] + #[arg(long, default_value = "10.0", value_name = "PERCENT")] pub tolerance: f64, /// Time limit for the verification benchmark. - #[clap(long, default_value = "5.0", value_name = "SECONDS")] + #[arg(long, default_value = "5.0", value_name = "SECONDS")] pub verify_duration: f32, /// Time limit for the hash function benchmark. - #[clap(long, default_value = "5.0", value_name = "SECONDS")] + #[arg(long, default_value = "5.0", value_name = "SECONDS")] pub hash_duration: f32, /// Time limit for the memory benchmark. - #[clap(long, default_value = "5.0", value_name = "SECONDS")] + #[arg(long, default_value = "5.0", value_name = "SECONDS")] pub memory_duration: f32, /// Time limit for each disk benchmark. - #[clap(long, default_value = "5.0", value_name = "SECONDS")] + #[arg(long, default_value = "5.0", value_name = "SECONDS")] pub disk_duration: f32, } diff --git a/utils/frame/benchmarking-cli/src/overhead/cmd.rs b/utils/frame/benchmarking-cli/src/overhead/cmd.rs index 93b0e7c472647..74c1e7efc24d4 100644 --- a/utils/frame/benchmarking-cli/src/overhead/cmd.rs +++ b/utils/frame/benchmarking-cli/src/overhead/cmd.rs @@ -73,13 +73,13 @@ pub struct OverheadParams { /// Add a header to the generated weight output file. /// /// Good for adding LICENSE headers. - #[clap(long, value_name = "PATH")] + #[arg(long, value_name = "PATH")] pub header: Option, /// Enable the Trie cache. /// /// This should only be used for performance analysis and not for final results. - #[clap(long)] + #[arg(long)] pub enable_trie_cache: bool, } diff --git a/utils/frame/benchmarking-cli/src/pallet/mod.rs b/utils/frame/benchmarking-cli/src/pallet/mod.rs index ae597f4054a81..7d172c5d497c2 100644 --- a/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -35,61 +35,61 @@ fn parse_pallet_name(pallet: &str) -> std::result::Result { #[derive(Debug, clap::Parser)] pub struct PalletCmd { /// Select a FRAME Pallet to benchmark, or `*` for all (in which case `extrinsic` must be `*`). - #[clap(short, long, value_parser = parse_pallet_name, required_unless_present = "list")] + #[arg(short, long, value_parser = parse_pallet_name, required_unless_present = "list")] pub pallet: Option, /// Select an extrinsic inside the pallet to benchmark, or `*` for all. - #[clap(short, long, required_unless_present = "list")] + #[arg(short, long, required_unless_present = "list")] pub extrinsic: Option, /// Select how many samples we should take across the variable components. - #[clap(short, long, default_value = "2")] + #[arg(short, long, default_value = "2")] pub steps: u32, /// Indicates lowest values for each of the component ranges. - #[clap(long = "low", value_delimiter = ',')] + #[arg(long = "low", value_delimiter = ',')] pub lowest_range_values: Vec, /// Indicates highest values for each of the component ranges. - #[clap(long = "high", value_delimiter = ',')] + #[arg(long = "high", value_delimiter = ',')] pub highest_range_values: Vec, /// Select how many repetitions of this benchmark should run from within the wasm. - #[clap(short, long, default_value = "1")] + #[arg(short, long, default_value = "1")] pub repeat: u32, /// Select how many repetitions of this benchmark should run from the client. /// /// NOTE: Using this alone may give slower results, but will afford you maximum Wasm memory. - #[clap(long, default_value = "1")] + #[arg(long, default_value = "1")] pub external_repeat: u32, /// Print the raw results in JSON format. - #[clap(long = "json")] + #[arg(long = "json")] pub json_output: bool, /// Write the raw results in JSON format into the given file. - #[clap(long, conflicts_with = "json_output")] + #[arg(long, conflicts_with = "json_output")] pub json_file: Option, /// Don't print the median-slopes linear regression analysis. - #[clap(long)] + #[arg(long)] pub no_median_slopes: bool, /// Don't print the min-squares linear regression analysis. - #[clap(long)] + #[arg(long)] pub no_min_squares: bool, /// Output the benchmarks to a Rust file at the given path. - #[clap(long)] + #[arg(long)] pub output: Option, /// Add a header file to your outputted benchmarks. - #[clap(long)] + #[arg(long)] pub header: Option, /// Path to Handlebars template file used for outputting benchmark results. (Optional) - #[clap(long)] + #[arg(long)] pub template: Option, #[allow(missing_docs)] @@ -100,25 +100,25 @@ pub struct PalletCmd { /// * min-squares (default) /// * median-slopes /// * max (max of min squares and median slopes for each value) - #[clap(long)] + #[arg(long)] pub output_analysis: Option, /// Set the heap pages while running benchmarks. If not set, the default value from the client /// is used. - #[clap(long)] + #[arg(long)] pub heap_pages: Option, /// Disable verification logic when running benchmarks. - #[clap(long)] + #[arg(long)] pub no_verify: bool, /// Display and run extra benchmarks that would otherwise not be needed for weight /// construction. - #[clap(long)] + #[arg(long)] pub extra: bool, /// Estimate PoV size. - #[clap(long)] + #[arg(long)] pub record_proof: bool, #[allow(missing_docs)] @@ -126,11 +126,11 @@ pub struct PalletCmd { pub shared_params: sc_cli::SharedParams, /// The execution strategy that should be used for benchmarks. - #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true)] + #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)] pub execution: Option, /// Method for executing Wasm runtime code. - #[clap( + #[arg( long = "wasm-execution", value_name = "METHOD", value_enum, @@ -142,7 +142,7 @@ pub struct PalletCmd { /// The WASM instantiation method to use. /// /// Only has an effect when `wasm-execution` is set to `compiled`. - #[clap( + #[arg( long = "wasm-instantiation-strategy", value_name = "STRATEGY", default_value_t = DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, @@ -151,19 +151,19 @@ pub struct PalletCmd { pub wasmtime_instantiation_strategy: WasmtimeInstantiationStrategy, /// Limit the memory the database cache can use. - #[clap(long = "db-cache", value_name = "MiB", default_value = "1024")] + #[arg(long = "db-cache", value_name = "MiB", default_value = "1024")] pub database_cache_size: u32, /// List the benchmarks that match your query rather than running them. /// /// When nothing is provided, we list all benchmarks. - #[clap(long)] + #[arg(long)] pub list: bool, /// If enabled, the storage info is not displayed in the output next to the analysis. /// /// This is independent of the storage info appearing in the *output file*. Use a Handlebar /// template for that purpose. - #[clap(long)] + #[arg(long)] pub no_storage_info: bool, } diff --git a/utils/frame/benchmarking-cli/src/shared/mod.rs b/utils/frame/benchmarking-cli/src/shared/mod.rs index 54368d77e0669..ea5415f33f020 100644 --- a/utils/frame/benchmarking-cli/src/shared/mod.rs +++ b/utils/frame/benchmarking-cli/src/shared/mod.rs @@ -98,19 +98,19 @@ pub fn check_build_profile() -> Result<(), String> { #[command(rename_all = "kebab-case")] pub struct HostInfoParams { /// Manually override the hostname to use. - #[clap(long)] + #[arg(long)] pub hostname_override: Option, /// Specify a fallback hostname if no-one could be detected automatically. /// /// Note: This only exists to make the `hostname` function infallible. - #[clap(long, default_value = "")] + #[arg(long, default_value = "")] pub hostname_fallback: String, /// Specify a fallback CPU name if no-one could be detected automatically. /// /// Note: This only exists to make the `cpuname` function infallible. - #[clap(long, default_value = "")] + #[arg(long, default_value = "")] pub cpuname_fallback: String, } diff --git a/utils/frame/benchmarking-cli/src/shared/weight_params.rs b/utils/frame/benchmarking-cli/src/shared/weight_params.rs index 4dd80cd41ff3d..7532815035959 100644 --- a/utils/frame/benchmarking-cli/src/shared/weight_params.rs +++ b/utils/frame/benchmarking-cli/src/shared/weight_params.rs @@ -31,23 +31,23 @@ pub struct WeightParams { /// File or directory to write the *weight* files to. /// /// For Substrate this should be `frame/support/src/weights`. - #[clap(long)] + #[arg(long)] pub weight_path: Option, /// Select a specific metric to calculate the final weight output. - #[clap(long = "metric", default_value = "average")] + #[arg(long = "metric", default_value = "average")] pub weight_metric: StatSelect, /// Multiply the resulting weight with the given factor. Must be positive. /// /// Is applied before `weight_add`. - #[clap(long = "mul", default_value = "1")] + #[arg(long = "mul", default_value = "1")] pub weight_mul: f64, /// Add the given offset to the resulting weight. /// /// Is applied after `weight_mul`. - #[clap(long = "add", default_value = "0")] + #[arg(long = "add", default_value = "0")] pub weight_add: u64, } diff --git a/utils/frame/benchmarking-cli/src/storage/cmd.rs b/utils/frame/benchmarking-cli/src/storage/cmd.rs index 3d4dad2a945ab..19615a55fffb9 100644 --- a/utils/frame/benchmarking-cli/src/storage/cmd.rs +++ b/utils/frame/benchmarking-cli/src/storage/cmd.rs @@ -68,54 +68,54 @@ pub struct StorageParams { pub hostinfo: HostInfoParams, /// Skip the `read` benchmark. - #[clap(long)] + #[arg(long)] pub skip_read: bool, /// Skip the `write` benchmark. - #[clap(long)] + #[arg(long)] pub skip_write: bool, /// Specify the Handlebars template to use for outputting benchmark results. - #[clap(long)] + #[arg(long)] pub template_path: Option, /// Add a header to the generated weight output file. /// /// Good for adding LICENSE headers. - #[clap(long, value_name = "PATH")] + #[arg(long, value_name = "PATH")] pub header: Option, /// Path to write the raw 'read' results in JSON format to. Can be a file or directory. - #[clap(long)] + #[arg(long)] pub json_read_path: Option, /// Path to write the raw 'write' results in JSON format to. Can be a file or directory. - #[clap(long)] + #[arg(long)] pub json_write_path: Option, /// Rounds of warmups before measuring. - #[clap(long, default_value = "1")] + #[arg(long, default_value = "1")] pub warmups: u32, /// The `StateVersion` to use. Substrate `--dev` should use `V1` and Polkadot `V0`. /// Selecting the wrong version can corrupt the DB. - #[clap(long, value_parser = ["0", "1"])] + #[arg(long, value_parser = ["0", "1"])] pub state_version: u8, /// Trie cache size in bytes. /// /// Providing `0` will disable the cache. - #[clap(long, value_name = "Bytes", default_value = "67108864")] + #[arg(long, value_name = "Bytes", default_value = "67108864")] pub trie_cache_size: usize, /// Enable the Trie cache. /// /// This should only be used for performance analysis and not for final results. - #[clap(long)] + #[arg(long)] pub enable_trie_cache: bool, /// Include child trees in benchmark. - #[clap(long)] + #[arg(long)] pub include_child_trees: bool, } diff --git a/utils/frame/frame-utilities-cli/src/pallet_id.rs b/utils/frame/frame-utilities-cli/src/pallet_id.rs index 9b5aa3e3bdd19..2a80e3a3d312d 100644 --- a/utils/frame/frame-utilities-cli/src/pallet_id.rs +++ b/utils/frame/frame-utilities-cli/src/pallet_id.rs @@ -34,7 +34,7 @@ pub struct PalletIdCmd { id: String, /// network address format - #[clap( + #[arg( long, value_name = "NETWORK", value_parser = sc_cli::parse_ss58_address_format, @@ -43,15 +43,15 @@ pub struct PalletIdCmd { pub network: Option, #[allow(missing_docs)] - #[clap(flatten)] + #[command(flatten)] pub output_scheme: OutputTypeFlag, #[allow(missing_docs)] - #[clap(flatten)] + #[command(flatten)] pub crypto_scheme: CryptoSchemeFlag, #[allow(missing_docs)] - #[clap(flatten)] + #[command(flatten)] pub keystore_params: KeystoreParams, } diff --git a/utils/frame/generate-bags/node-runtime/src/main.rs b/utils/frame/generate-bags/node-runtime/src/main.rs index 5ea1262d95d34..66d5b0f51de2c 100644 --- a/utils/frame/generate-bags/node-runtime/src/main.rs +++ b/utils/frame/generate-bags/node-runtime/src/main.rs @@ -25,19 +25,19 @@ use std::path::PathBuf; // #[clap(author, version, about)] struct Opt { /// How many bags to generate. - #[clap(long, default_value = "200")] + #[arg(long, default_value = "200")] n_bags: usize, /// Where to write the output. output: PathBuf, /// The total issuance of the currency used to create `VoteWeight`. - #[clap(short, long)] + #[arg(short, long)] total_issuance: u128, /// The minimum account balance (i.e. existential deposit) for the currency used to create /// `VoteWeight`. - #[clap(short, long)] + #[arg(short, long)] minimum_balance: u128, } diff --git a/utils/frame/try-runtime/cli/src/commands/execute_block.rs b/utils/frame/try-runtime/cli/src/commands/execute_block.rs index 711de2127b404..df8c51b5a92d4 100644 --- a/utils/frame/try-runtime/cli/src/commands/execute_block.rs +++ b/utils/frame/try-runtime/cli/src/commands/execute_block.rs @@ -33,11 +33,11 @@ use std::{fmt::Debug, str::FromStr}; #[derive(Debug, Clone, clap::Parser)] pub struct ExecuteBlockCmd { /// Overwrite the wasm code in state or not. - #[clap(long)] + #[arg(long)] overwrite_wasm_code: bool, /// If set the state root check is disabled. - #[clap(long)] + #[arg(long)] no_state_root_check: bool, /// Which try-state targets to execute when running this command. @@ -49,14 +49,14 @@ pub struct ExecuteBlockCmd { /// `Staking, System`). /// - `rr-[x]` where `[x]` is a number. Then, the given number of pallets are checked in a /// round-robin fashion. - #[clap(long, default_value = "none")] + #[arg(long, default_value = "none")] try_state: frame_try_runtime::TryStateSelect, /// The block hash at which to fetch the block. /// /// If the `live` state type is being used, then this can be omitted, and is equal to whatever /// the `state::at` is. Only use this (with care) when combined with a snapshot. - #[clap( + #[arg( long, value_parser = crate::parse::hash )] @@ -66,7 +66,7 @@ pub struct ExecuteBlockCmd { /// /// If the `live` state type is being used, then this can be omitted, and is equal to whatever /// the `state::uri` is. Only use this (with care) when combined with a snapshot. - #[clap( + #[arg( long, value_parser = crate::parse::url )] @@ -77,7 +77,7 @@ pub struct ExecuteBlockCmd { /// For this command only, if the `live` is used, then state of the parent block is fetched. /// /// If `block_at` is provided, then the [`State::Live::at`] is being ignored. - #[clap(subcommand)] + #[command(subcommand)] state: State, } diff --git a/utils/frame/try-runtime/cli/src/commands/follow_chain.rs b/utils/frame/try-runtime/cli/src/commands/follow_chain.rs index 96ad635abe63c..e982cd18380e5 100644 --- a/utils/frame/try-runtime/cli/src/commands/follow_chain.rs +++ b/utils/frame/try-runtime/cli/src/commands/follow_chain.rs @@ -42,11 +42,11 @@ const UN_SUB: &str = "chain_unsubscribeFinalizedHeads"; #[derive(Debug, Clone, clap::Parser)] pub struct FollowChainCmd { /// The url to connect to. - #[clap(short, long, value_parser = parse::url)] + #[arg(short, long, value_parser = parse::url)] uri: String, /// If set, then the state root check is enabled. - #[clap(long)] + #[arg(long)] state_root_check: bool, /// Which try-state targets to execute when running this command. @@ -58,11 +58,11 @@ pub struct FollowChainCmd { /// `Staking, System`). /// - `rr-[x]` where `[x]` is a number. Then, the given number of pallets are checked in a /// round-robin fashion. - #[clap(long, default_value = "none")] + #[arg(long, default_value = "none")] try_state: frame_try_runtime::TryStateSelect, /// If present, a single connection to a node will be kept and reused for fetching blocks. - #[clap(long)] + #[arg(long)] keep_connection: bool, } diff --git a/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs b/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs index 13788dd8313ea..6f48d1f8f68a7 100644 --- a/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs +++ b/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs @@ -31,14 +31,14 @@ use std::{fmt::Debug, str::FromStr}; #[derive(Debug, Clone, clap::Parser)] pub struct OffchainWorkerCmd { /// Overwrite the wasm code in state or not. - #[clap(long)] + #[arg(long)] overwrite_wasm_code: bool, /// The block hash at which to fetch the header. /// /// If the `live` state type is being used, then this can be omitted, and is equal to whatever /// the `state::at` is. Only use this (with care) when combined with a snapshot. - #[clap( + #[arg( long, value_parser = parse::hash )] @@ -48,14 +48,14 @@ pub struct OffchainWorkerCmd { /// /// If the `live` state type is being used, then this can be omitted, and is equal to whatever /// the `state::uri` is. Only use this (with care) when combined with a snapshot. - #[clap( + #[arg( long, value_parser = parse::url )] header_ws_uri: Option, /// The state type to use. - #[clap(subcommand)] + #[command(subcommand)] pub state: State, } diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index f6a7223b146db..6347fa7573951 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -392,11 +392,11 @@ pub struct SharedParams { pub shared_params: sc_cli::SharedParams, /// The execution strategy that should be used. - #[clap(long, value_name = "STRATEGY", value_enum, ignore_case = true, default_value = "wasm")] + #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true, default_value = "wasm")] pub execution: ExecutionStrategy, /// Type of wasm execution used. - #[clap( + #[arg( long = "wasm-execution", value_name = "METHOD", value_enum, @@ -408,7 +408,7 @@ pub struct SharedParams { /// The WASM instantiation method to use. /// /// Only has an effect when `wasm-execution` is set to `compiled`. - #[clap( + #[arg( long = "wasm-instantiation-strategy", value_name = "STRATEGY", default_value_t = DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, @@ -418,15 +418,15 @@ pub struct SharedParams { /// The number of 64KB pages to allocate for Wasm execution. Defaults to /// [`sc_service::Configuration.default_heap_pages`]. - #[clap(long)] + #[arg(long)] pub heap_pages: Option, /// When enabled, the spec check will not panic, and instead only show a warning. - #[clap(long)] + #[arg(long)] pub no_spec_check_panic: bool, /// State version that is used by the chain. - #[clap(long, default_value = "1", value_parser = parse::state_version)] + #[arg(long, default_value = "1", value_parser = parse::state_version)] pub state_version: StateVersion, } @@ -438,7 +438,7 @@ pub struct TryRuntimeCmd { #[clap(flatten)] pub shared: SharedParams, - #[clap(subcommand)] + #[command(subcommand)] pub command: Command, } @@ -449,14 +449,14 @@ pub enum State { /// /// This can be crated by passing a value to [`State::Live::snapshot_path`]. Snap { - #[clap(short, long)] + #[arg(short, long)] snapshot_path: PathBuf, }, /// Use a live chain as the source of runtime state. Live { /// The url to connect to. - #[clap( + #[arg( short, long, value_parser = parse::url, @@ -467,7 +467,7 @@ pub enum State { /// /// If non provided, then the latest finalized head is used. This is particularly useful /// for [`Command::OnRuntimeUpgrade`]. - #[clap( + #[arg( short, long, value_parser = parse::hash, @@ -475,12 +475,12 @@ pub enum State { at: Option, /// An optional state snapshot file to WRITE to. Not written if set to `None`. - #[clap(short, long)] + #[arg(short, long)] snapshot_path: Option, /// A pallet to scrape. Can be provided multiple times. If empty, entire chain state will /// be scraped. - #[clap(short, long, num_args = 0..)] + #[arg(short, long, num_args = 0..)] pallet: Vec, /// Fetch the child-keys as well. @@ -488,7 +488,7 @@ pub enum State { /// Default is `false`, if specific `--pallets` are specified, `true` otherwise. In other /// words, if you scrape the whole state the child tree data is included out of the box. /// Otherwise, it must be enabled explicitly using this flag. - #[clap(long)] + #[arg(long)] child_tree: bool, }, } From d21239171c04767f4bc9072d020f400b74b47fdf Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Wed, 5 Oct 2022 15:15:02 +0200 Subject: [PATCH 10/20] Remove no-op value_parsers --- client/cli/src/commands/export_blocks_cmd.rs | 2 +- client/cli/src/commands/import_blocks_cmd.rs | 2 +- client/cli/src/params/import_params.rs | 2 +- client/cli/src/params/keystore_params.rs | 3 +-- client/cli/src/params/shared_params.rs | 2 +- scripts/ci/node-template-release/Cargo.toml | 2 +- scripts/ci/node-template-release/src/main.rs | 4 ++-- 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/client/cli/src/commands/export_blocks_cmd.rs b/client/cli/src/commands/export_blocks_cmd.rs index 6cabfd57503ab..e2f83200e511c 100644 --- a/client/cli/src/commands/export_blocks_cmd.rs +++ b/client/cli/src/commands/export_blocks_cmd.rs @@ -32,7 +32,7 @@ use std::{fmt::Debug, fs, io, path::PathBuf, str::FromStr, sync::Arc}; #[derive(Debug, Clone, Parser)] pub struct ExportBlocksCmd { /// Output file name or stdout if unspecified. - #[arg(value_parser)] + #[arg()] pub output: Option, /// Specify starting block number. diff --git a/client/cli/src/commands/import_blocks_cmd.rs b/client/cli/src/commands/import_blocks_cmd.rs index 85214a27fc042..debc697242ddd 100644 --- a/client/cli/src/commands/import_blocks_cmd.rs +++ b/client/cli/src/commands/import_blocks_cmd.rs @@ -37,7 +37,7 @@ use std::{ #[derive(Debug, Parser)] pub struct ImportBlocksCmd { /// Input file or stdin if unspecified. - #[arg(value_parser)] + #[arg()] pub input: Option, /// The default number of 64KB pages to ever allocate for Wasm execution. diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs index 74728fd3cfc06..4884a01e38e52 100644 --- a/client/cli/src/params/import_params.rs +++ b/client/cli/src/params/import_params.rs @@ -87,7 +87,7 @@ pub struct ImportParams { /// Specify the path where local WASM runtimes are stored. /// /// These runtimes will override on-chain runtimes when the version matches. - #[arg(long, value_name = "PATH", value_parser)] + #[arg(long, value_name = "PATH")] pub wasm_runtime_overrides: Option, #[allow(missing_docs)] diff --git a/client/cli/src/params/keystore_params.rs b/client/cli/src/params/keystore_params.rs index 23a20051b82b3..d6c3c35d82418 100644 --- a/client/cli/src/params/keystore_params.rs +++ b/client/cli/src/params/keystore_params.rs @@ -36,7 +36,7 @@ pub struct KeystoreParams { pub keystore_uri: Option, /// Specify custom keystore path. - #[arg(long, value_name = "PATH", value_parser)] + #[arg(long, value_name = "PATH")] pub keystore_path: Option, /// Use interactive shell for entering the password used by the keystore. @@ -56,7 +56,6 @@ pub struct KeystoreParams { #[arg( long, value_name = "PATH", - value_parser, conflicts_with_all = &["password_interactive", "password"] )] pub password_filename: Option, diff --git a/client/cli/src/params/shared_params.rs b/client/cli/src/params/shared_params.rs index 52937cefbbffb..5ffa73229e1bc 100644 --- a/client/cli/src/params/shared_params.rs +++ b/client/cli/src/params/shared_params.rs @@ -39,7 +39,7 @@ pub struct SharedParams { pub dev: bool, /// Specify custom base path. - #[arg(long, short = 'd', value_name = "PATH", value_parser)] + #[arg(long, short = 'd', value_name = "PATH")] pub base_path: Option, /// Sets a custom logging filter. Syntax is =, e.g. -lsync=debug. diff --git a/scripts/ci/node-template-release/Cargo.toml b/scripts/ci/node-template-release/Cargo.toml index 8871a04e19b16..046f28501c765 100644 --- a/scripts/ci/node-template-release/Cargo.toml +++ b/scripts/ci/node-template-release/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://substrate.io" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "3.0", features = ["derive"] } +clap = { version = "4.0.9", features = ["derive", "deprecated"] } flate2 = "1.0" fs_extra = "1" git2 = "0.8" diff --git a/scripts/ci/node-template-release/src/main.rs b/scripts/ci/node-template-release/src/main.rs index 20ac44148feff..91a7e865458cf 100644 --- a/scripts/ci/node-template-release/src/main.rs +++ b/scripts/ci/node-template-release/src/main.rs @@ -29,10 +29,10 @@ type CargoToml = HashMap; #[derive(Parser)] struct Options { /// The path to the `node-template` source. - #[arg(value_parser)] + #[arg()] node_template: PathBuf, /// The path where to output the generated `tar.gz` file. - #[arg(value_parser)] + #[arg()] output: PathBuf, } From a6181b6e9e88d0177c63751cbe8e85f25d497818 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Fri, 7 Oct 2022 16:49:56 +0200 Subject: [PATCH 11/20] Adjust value_parser for state_version --- utils/frame/benchmarking-cli/src/storage/cmd.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/frame/benchmarking-cli/src/storage/cmd.rs b/utils/frame/benchmarking-cli/src/storage/cmd.rs index 19615a55fffb9..1cb2a05f47f31 100644 --- a/utils/frame/benchmarking-cli/src/storage/cmd.rs +++ b/utils/frame/benchmarking-cli/src/storage/cmd.rs @@ -26,7 +26,10 @@ use sp_runtime::traits::{Block as BlockT, HashFor}; use sp_state_machine::Storage; use sp_storage::{ChildInfo, ChildType, PrefixedStorageKey, StateVersion}; -use clap::{Args, Parser}; +use clap::{ + builder::{PossibleValuesParser, TypedValueParser}, + Args, Parser, +}; use log::info; use rand::prelude::*; use serde::Serialize; @@ -99,7 +102,7 @@ pub struct StorageParams { /// The `StateVersion` to use. Substrate `--dev` should use `V1` and Polkadot `V0`. /// Selecting the wrong version can corrupt the DB. - #[arg(long, value_parser = ["0", "1"])] + #[arg(long, value_parser = PossibleValuesParser::new(["0", "1"]).map(|v| v.parse::().expect("0 and 1 can be parsed to u8; qed")))] pub state_version: u8, /// Trie cache size in bytes. From 5c929ddb87ae34a6c5f76eacbd964afa3e9ed834 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Sun, 9 Oct 2022 14:37:33 +0200 Subject: [PATCH 12/20] Remove "deprecated" feature flag and bump to 4.0.11 --- Cargo.lock | 36 +++++++++---------- bin/node-template/node/Cargo.toml | 2 +- bin/node/bench/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 2 +- bin/node/inspect/Cargo.toml | 2 +- bin/utils/chain-spec-builder/Cargo.toml | 2 +- bin/utils/subkey/Cargo.toml | 2 +- client/cli/Cargo.toml | 2 +- .../solution-type/fuzzer/Cargo.toml | 2 +- primitives/npos-elections/fuzzer/Cargo.toml | 2 +- scripts/ci/node-template-release/Cargo.toml | 2 +- utils/frame/benchmarking-cli/Cargo.toml | 2 +- utils/frame/frame-utilities-cli/Cargo.toml | 2 +- .../generate-bags/node-runtime/Cargo.toml | 2 +- utils/frame/try-runtime/cli/Cargo.toml | 2 +- 15 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 194af5df35d4c..32a2a11827170 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -920,7 +920,7 @@ name = "chain-spec-builder" version = "2.0.0" dependencies = [ "ansi_term", - "clap 4.0.9", + "clap 4.0.11", "node-cli", "rand 0.8.5", "sc-chain-spec", @@ -997,9 +997,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.9" +version = "4.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30607dd93c420c6f1f80b544be522a0238a7db35e6a12968d28910983fee0df0" +checksum = "4ed45cc2c62a3eff523e718d8576ba762c83a3146151093283ac62ae11933a73" dependencies = [ "atty", "bitflags", @@ -1016,14 +1016,14 @@ version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11cba7abac9b56dfe2f035098cdb3a43946f276e6db83b72c4e692343f9aab9a" dependencies = [ - "clap 4.0.9", + "clap 4.0.11", ] [[package]] name = "clap_derive" -version = "4.0.9" +version = "4.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a307492e1a34939f79d3b6b9650bd2b971513cd775436bf2b78defeb5af00b" +checksum = "db342ce9fda24fb191e2ed4e102055a4d381c1086a06630174cd8da8d5d917ce" dependencies = [ "heck", "proc-macro-error", @@ -2145,7 +2145,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 4.0.9", + "clap 4.0.11", "comfy-table", "frame-benchmarking", "frame-support", @@ -2226,7 +2226,7 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.0.9", + "clap 4.0.11", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", @@ -4612,7 +4612,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes", - "clap 4.0.9", + "clap 4.0.11", "derive_more", "fs_extra", "futures", @@ -4651,7 +4651,7 @@ dependencies = [ "array-bytes", "assert_cmd", "async-std", - "clap 4.0.9", + "clap 4.0.11", "clap_complete", "criterion", "frame-benchmarking-cli", @@ -4768,7 +4768,7 @@ dependencies = [ name = "node-inspect" version = "0.9.0-dev" dependencies = [ - "clap 4.0.9", + "clap 4.0.11", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -4827,7 +4827,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 4.0.9", + "clap 4.0.11", "generate-bags", "kitchensink-runtime", ] @@ -4836,7 +4836,7 @@ dependencies = [ name = "node-template" version = "4.0.0-dev" dependencies = [ - "clap 4.0.9", + "clap 4.0.11", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -7888,7 +7888,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "chrono", - "clap 4.0.9", + "clap 4.0.11", "fdlimit", "futures", "libp2p", @@ -9993,7 +9993,7 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.0.9", + "clap 4.0.11", "honggfuzz", "parity-scale-codec", "rand 0.8.5", @@ -10490,7 +10490,7 @@ dependencies = [ name = "subkey" version = "2.0.2" dependencies = [ - "clap 4.0.9", + "clap 4.0.11", "sc-cli", ] @@ -10518,7 +10518,7 @@ dependencies = [ name = "substrate-frame-cli" version = "4.0.0-dev" dependencies = [ - "clap 4.0.9", + "clap 4.0.11", "frame-support", "frame-system", "sc-cli", @@ -11258,7 +11258,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" name = "try-runtime-cli" version = "0.10.0-dev" dependencies = [ - "clap 4.0.9", + "clap 4.0.11", "frame-try-runtime", "jsonrpsee", "log", diff --git a/bin/node-template/node/Cargo.toml b/bin/node-template/node/Cargo.toml index 25eda3dd5d8c5..c60018e14969c 100644 --- a/bin/node-template/node/Cargo.toml +++ b/bin/node-template/node/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] name = "node-template" [dependencies] -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } sc-cli = { version = "0.10.0-dev", path = "../../../client/cli", features = ["wasmtime"] } sp-core = { version = "6.0.0", path = "../../../primitives/core" } diff --git a/bin/node/bench/Cargo.toml b/bin/node/bench/Cargo.toml index fd27aade888ad..54a1d4900c60b 100644 --- a/bin/node/bench/Cargo.toml +++ b/bin/node/bench/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/" [dependencies] array-bytes = "4.1" -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } log = "0.4.17" node-primitives = { version = "2.0.0", path = "../primitives" } node-testing = { version = "3.0.0-dev", path = "../testing" } diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 3be292083c40a..25e7ef095ed3e 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -35,7 +35,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] # third-party dependencies array-bytes = "4.1" -clap = { version = "4.0.9", features = ["derive", "deprecated"], optional = true } +clap = { version = "4.0.9", features = ["derive"], optional = true } codec = { package = "parity-scale-codec", version = "3.0.0" } serde = { version = "1.0.136", features = ["derive"] } jsonrpsee = { version = "0.15.1", features = ["server"] } diff --git a/bin/node/inspect/Cargo.toml b/bin/node/inspect/Cargo.toml index 67728b0aa08f0..b7eccf9c36bd2 100644 --- a/bin/node/inspect/Cargo.toml +++ b/bin/node/inspect/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0" } thiserror = "1.0" sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" } diff --git a/bin/utils/chain-spec-builder/Cargo.toml b/bin/utils/chain-spec-builder/Cargo.toml index 72fad4d09108a..dc53dc08ec6af 100644 --- a/bin/utils/chain-spec-builder/Cargo.toml +++ b/bin/utils/chain-spec-builder/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] ansi_term = "0.12.1" -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } rand = "0.8" node-cli = { version = "3.0.0-dev", path = "../../node/cli" } sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" } diff --git a/bin/utils/subkey/Cargo.toml b/bin/utils/subkey/Cargo.toml index d4d39d3f37270..77c323821a508 100644 --- a/bin/utils/subkey/Cargo.toml +++ b/bin/utils/subkey/Cargo.toml @@ -17,5 +17,5 @@ path = "src/main.rs" name = "subkey" [dependencies] -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" } diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 370f0ca805c82..a4f44bdd6e8c4 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" chrono = "0.4.10" -clap = { version = "4.0.9", features = ["derive", "deprecated", "string"] } +clap = { version = "4.0.9", features = ["derive", "string"] } fdlimit = "0.2.1" futures = "0.3.21" libp2p = "0.46.1" diff --git a/frame/election-provider-support/solution-type/fuzzer/Cargo.toml b/frame/election-provider-support/solution-type/fuzzer/Cargo.toml index d662ced515378..2cc620452586d 100644 --- a/frame/election-provider-support/solution-type/fuzzer/Cargo.toml +++ b/frame/election-provider-support/solution-type/fuzzer/Cargo.toml @@ -13,7 +13,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } honggfuzz = "0.5" rand = { version = "0.8", features = ["std", "small_rng"] } diff --git a/primitives/npos-elections/fuzzer/Cargo.toml b/primitives/npos-elections/fuzzer/Cargo.toml index cbbe4851d3642..293a17624820b 100644 --- a/primitives/npos-elections/fuzzer/Cargo.toml +++ b/primitives/npos-elections/fuzzer/Cargo.toml @@ -14,7 +14,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } honggfuzz = "0.5" rand = { version = "0.8", features = ["std", "small_rng"] } diff --git a/scripts/ci/node-template-release/Cargo.toml b/scripts/ci/node-template-release/Cargo.toml index 046f28501c765..0800b17536453 100644 --- a/scripts/ci/node-template-release/Cargo.toml +++ b/scripts/ci/node-template-release/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://substrate.io" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } flate2 = "1.0" fs_extra = "1" git2 = "0.8" diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index dde933804a022..ea908bf0336bf 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" chrono = "0.4" -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0" } comfy-table = { version = "6.0.0", default-features = false } handlebars = "4.2.2" diff --git a/utils/frame/frame-utilities-cli/Cargo.toml b/utils/frame/frame-utilities-cli/Cargo.toml index d5cc8c1d4d8a2..89e9ee79db214 100644 --- a/utils/frame/frame-utilities-cli/Cargo.toml +++ b/utils/frame/frame-utilities-cli/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/substrate-frame-cli" readme = "README.md" [dependencies] -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } frame-support = { version = "4.0.0-dev", path = "../../../frame/support" } frame-system = { version = "4.0.0-dev", path = "../../../frame/system" } sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" } diff --git a/utils/frame/generate-bags/node-runtime/Cargo.toml b/utils/frame/generate-bags/node-runtime/Cargo.toml index 0ad6d574302f2..6cc14a0595501 100644 --- a/utils/frame/generate-bags/node-runtime/Cargo.toml +++ b/utils/frame/generate-bags/node-runtime/Cargo.toml @@ -14,4 +14,4 @@ kitchensink-runtime = { version = "3.0.0-dev", path = "../../../../bin/node/runt generate-bags = { version = "4.0.0-dev", path = "../" } # third-party -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } diff --git a/utils/frame/try-runtime/cli/Cargo.toml b/utils/frame/try-runtime/cli/Cargo.toml index bea21d857e28e..96df69dcbbe6f 100644 --- a/utils/frame/try-runtime/cli/Cargo.toml +++ b/utils/frame/try-runtime/cli/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "4.0.9", features = ["derive", "deprecated"] } +clap = { version = "4.0.9", features = ["derive"] } log = "0.4.17" parity-scale-codec = "3.0.0" serde = "1.0.136" From a84300bca2e9836fb41d2c60d4198d8923b6c7e9 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Mon, 10 Oct 2022 08:55:26 +0200 Subject: [PATCH 13/20] Improve range MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- utils/frame/benchmarking-cli/src/storage/cmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/frame/benchmarking-cli/src/storage/cmd.rs b/utils/frame/benchmarking-cli/src/storage/cmd.rs index 1cb2a05f47f31..02de7d7f5b98a 100644 --- a/utils/frame/benchmarking-cli/src/storage/cmd.rs +++ b/utils/frame/benchmarking-cli/src/storage/cmd.rs @@ -102,7 +102,7 @@ pub struct StorageParams { /// The `StateVersion` to use. Substrate `--dev` should use `V1` and Polkadot `V0`. /// Selecting the wrong version can corrupt the DB. - #[arg(long, value_parser = PossibleValuesParser::new(["0", "1"]).map(|v| v.parse::().expect("0 and 1 can be parsed to u8; qed")))] + #[arg(long, value_parser = clap::value_parser!(u8).range(0..=1))] pub state_version: u8, /// Trie cache size in bytes. From cb3fe5d45ec14f05049fa3bc1326a4ff6898289d Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Mon, 10 Oct 2022 08:59:55 +0200 Subject: [PATCH 14/20] Apply suggestions --- bin/node/inspect/src/cli.rs | 1 - client/cli/src/params/mod.rs | 3 --- utils/frame/benchmarking-cli/src/storage/cmd.rs | 5 +---- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/bin/node/inspect/src/cli.rs b/bin/node/inspect/src/cli.rs index 8769778741651..fa6344ac346e9 100644 --- a/bin/node/inspect/src/cli.rs +++ b/bin/node/inspect/src/cli.rs @@ -18,7 +18,6 @@ //! Structs to easily compose inspect sub-command for CLI. -use clap::arg; use sc_cli::{ImportParams, SharedParams}; /// The `inspect` command used to print decoded chain data. diff --git a/client/cli/src/params/mod.rs b/client/cli/src/params/mod.rs index 6afaae28b5b87..6c738dbd6fa69 100644 --- a/client/cli/src/params/mod.rs +++ b/client/cli/src/params/mod.rs @@ -40,9 +40,6 @@ pub use crate::params::{ transaction_pool_params::*, }; -#[derive(Clone, Debug)] -struct FormatRegistryWrapper(Ss58AddressFormatRegistry); - /// Parse Ss58AddressFormat pub fn parse_ss58_address_format(x: &str) -> Result { match Ss58AddressFormatRegistry::try_from(x) { diff --git a/utils/frame/benchmarking-cli/src/storage/cmd.rs b/utils/frame/benchmarking-cli/src/storage/cmd.rs index 02de7d7f5b98a..b0a5dcff1bbc9 100644 --- a/utils/frame/benchmarking-cli/src/storage/cmd.rs +++ b/utils/frame/benchmarking-cli/src/storage/cmd.rs @@ -26,10 +26,7 @@ use sp_runtime::traits::{Block as BlockT, HashFor}; use sp_state_machine::Storage; use sp_storage::{ChildInfo, ChildType, PrefixedStorageKey, StateVersion}; -use clap::{ - builder::{PossibleValuesParser, TypedValueParser}, - Args, Parser, -}; +use clap::{Args, Parser}; use log::info; use rand::prelude::*; use serde::Serialize; From a6491a2522c88b5742c44bad741e1afc6c61940b Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Mon, 10 Oct 2022 16:31:24 +0200 Subject: [PATCH 15/20] Trigger CI From 35ec929a7d5d6d4bbfdbffbaeb7ccf885e2f618c Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Tue, 11 Oct 2022 11:33:43 +0200 Subject: [PATCH 16/20] Fix unused error warning --- client/cli/src/params/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/cli/src/params/mod.rs b/client/cli/src/params/mod.rs index 6c738dbd6fa69..b0b04e00fc042 100644 --- a/client/cli/src/params/mod.rs +++ b/client/cli/src/params/mod.rs @@ -44,7 +44,7 @@ pub use crate::params::{ pub fn parse_ss58_address_format(x: &str) -> Result { match Ss58AddressFormatRegistry::try_from(x) { Ok(format_registry) => Ok(format_registry.into()), - Err(e) => Err(format!( + Err(_) => Err(format!( "Unable to parse variant. Known variants: {:?}", Ss58AddressFormat::all_names() )), From 9381446d7c32c50199d269af47fd60008be6367d Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Tue, 11 Oct 2022 12:18:41 +0200 Subject: [PATCH 17/20] Fix doc errors --- client/cli/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index c1d3d9af83316..b6d0d47e52c1f 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -153,8 +153,8 @@ pub trait SubstrateCli: Sized { /// /// **NOTE:** This method WILL NOT exit when `--help` or `--version` (or short versions) are /// used. It will return a [`clap::Error`], where the [`clap::Error::kind`] is a - /// [`clap::ErrorKind::DisplayHelp`] or [`clap::ErrorKind::DisplayVersion`] respectively. - /// You must call [`clap::Error::exit`] or perform a [`std::process::exit`]. + /// [`clap::error::ErrorKind::DisplayHelp`] or [`clap::error::ErrorKind::DisplayVersion`] + /// respectively. You must call [`clap::Error::exit`] or perform a [`std::process::exit`]. fn try_from_iter(iter: I) -> clap::error::Result where Self: Parser + Sized, From 2b807495824b669a1446261b4e79078a59abaa58 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Tue, 11 Oct 2022 13:13:08 +0200 Subject: [PATCH 18/20] Fix ArgGroup naming conflict --- utils/frame/try-runtime/cli/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index 6347fa7573951..ec3053b7ed76b 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -385,6 +385,7 @@ pub enum Command { /// Shared parameters of the `try-runtime` commands #[derive(Debug, Clone, clap::Parser)] +#[group(skip)] pub struct SharedParams { /// Shared parameters of substrate cli. #[allow(missing_docs)] From fed8da7b430d4630283913696aa34d261e70ef7a Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Mon, 17 Oct 2022 14:00:23 +0200 Subject: [PATCH 19/20] Change default_value to default_value_t --- bin/utils/chain-spec-builder/src/main.rs | 4 ++-- client/cli/src/arg_enums.rs | 4 ++-- client/cli/src/commands/run_cmd.rs | 4 ++-- client/cli/src/params/import_params.rs | 4 ++-- client/cli/src/params/mod.rs | 4 ++-- client/cli/src/params/network_params.rs | 10 +++++----- client/cli/src/params/node_key_params.rs | 2 +- client/cli/src/params/offchain_worker_params.rs | 2 +- client/cli/src/params/shared_params.rs | 2 +- client/cli/src/params/transaction_pool_params.rs | 4 ++-- primitives/storage/src/lib.rs | 11 +++++++++++ utils/frame/benchmarking-cli/src/block/bench.rs | 2 +- utils/frame/benchmarking-cli/src/extrinsic/bench.rs | 4 ++-- utils/frame/benchmarking-cli/src/machine/mod.rs | 10 +++++----- utils/frame/benchmarking-cli/src/pallet/mod.rs | 10 +++++----- .../benchmarking-cli/src/shared/weight_params.rs | 4 ++-- utils/frame/benchmarking-cli/src/storage/cmd.rs | 4 ++-- utils/frame/generate-bags/node-runtime/src/main.rs | 2 +- utils/frame/try-runtime/cli/src/lib.rs | 6 +++--- 19 files changed, 52 insertions(+), 41 deletions(-) diff --git a/bin/utils/chain-spec-builder/src/main.rs b/bin/utils/chain-spec-builder/src/main.rs index f3ec4cbdf5188..7dfcaed773f40 100644 --- a/bin/utils/chain-spec-builder/src/main.rs +++ b/bin/utils/chain-spec-builder/src/main.rs @@ -68,10 +68,10 @@ enum ChainSpecBuilder { /// The number of nominators backing the aforementioned authorities. /// /// Will nominate a random subset of `authorities`. - #[arg(long, short, default_value = "0")] + #[arg(long, short, default_value_t = 0)] nominators: usize, /// The number of endowed accounts. - #[arg(long, short, default_value = "0")] + #[arg(long, short, default_value_t = 0)] endowed: usize, /// The path where the chain spec should be saved. #[arg(long, short, default_value = "./chain_spec.json")] diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index 8b03330cac325..d761c854a6f0d 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -145,11 +145,11 @@ pub fn execution_method_from_cli( /// The default [`WasmExecutionMethod`]. #[cfg(feature = "wasmtime")] -pub const DEFAULT_WASM_EXECUTION_METHOD: &str = "compiled"; +pub const DEFAULT_WASM_EXECUTION_METHOD: WasmExecutionMethod = WasmExecutionMethod::Compiled; /// The default [`WasmExecutionMethod`]. #[cfg(not(feature = "wasmtime"))] -pub const DEFAULT_WASM_EXECUTION_METHOD: &str = "interpreted-i-know-what-i-do"; +pub const DEFAULT_WASM_EXECUTION_METHOD: WasmExecutionMethod = WasmExecutionMethod::Interpreted; #[allow(missing_docs)] #[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)] diff --git a/client/cli/src/commands/run_cmd.rs b/client/cli/src/commands/run_cmd.rs index 36e70e8530e90..35181d83f805f 100644 --- a/client/cli/src/commands/run_cmd.rs +++ b/client/cli/src/commands/run_cmd.rs @@ -76,7 +76,7 @@ pub struct RunCmd { value_name = "METHOD SET", value_enum, ignore_case = true, - default_value = "auto", + default_value_t = RpcMethods::Auto, verbatim_doc_comment )] pub rpc_methods: RpcMethods, @@ -250,7 +250,7 @@ pub struct RunCmd { pub max_runtime_instances: Option, /// Maximum number of different runtimes that can be cached. - #[arg(long, default_value = "2")] + #[arg(long, default_value_t = 2)] pub runtime_cache_size: u8, /// Run a temporary node. diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs index 17ac8792b12f2..b7ccbf1c8ed55 100644 --- a/client/cli/src/params/import_params.rs +++ b/client/cli/src/params/import_params.rs @@ -47,7 +47,7 @@ pub struct ImportParams { value_name = "METHOD", value_enum, ignore_case = true, - default_value = DEFAULT_WASM_EXECUTION_METHOD, + default_value_t = DEFAULT_WASM_EXECUTION_METHOD, )] pub wasm_method: WasmExecutionMethod, @@ -85,7 +85,7 @@ pub struct ImportParams { /// Specify the state cache size. /// /// Providing `0` will disable the cache. - #[arg(long, value_name = "Bytes", default_value = "67108864")] + #[arg(long, value_name = "Bytes", default_value_t = 67108864)] pub trie_cache_size: usize, /// DEPRECATED diff --git a/client/cli/src/params/mod.rs b/client/cli/src/params/mod.rs index b0b04e00fc042..3197deb101bcc 100644 --- a/client/cli/src/params/mod.rs +++ b/client/cli/src/params/mod.rs @@ -129,7 +129,7 @@ impl BlockNumberOrHash { #[derive(Debug, Clone, Args)] pub struct CryptoSchemeFlag { /// cryptography scheme - #[arg(long, value_name = "SCHEME", value_enum, ignore_case = true, default_value = "sr25519")] + #[arg(long, value_name = "SCHEME", value_enum, ignore_case = true, default_value_t = CryptoScheme::Sr25519)] pub scheme: CryptoScheme, } @@ -137,7 +137,7 @@ pub struct CryptoSchemeFlag { #[derive(Debug, Clone, Args)] pub struct OutputTypeFlag { /// output format - #[arg(long, value_name = "FORMAT", value_enum, ignore_case = true, default_value = "text")] + #[arg(long, value_name = "FORMAT", value_enum, ignore_case = true, default_value_t = OutputType::Text)] pub output_type: OutputType, } diff --git a/client/cli/src/params/network_params.rs b/client/cli/src/params/network_params.rs index 0a9e1450ee81c..1bd4109710bb4 100644 --- a/client/cli/src/params/network_params.rs +++ b/client/cli/src/params/network_params.rs @@ -82,14 +82,14 @@ pub struct NetworkParams { pub allow_private_ipv4: bool, /// Specify the number of outgoing connections we're trying to maintain. - #[arg(long, value_name = "COUNT", default_value = "25")] + #[arg(long, value_name = "COUNT", default_value_t = 25)] pub out_peers: u32, /// Maximum number of inbound full nodes peers. - #[arg(long, value_name = "COUNT", default_value = "25")] + #[arg(long, value_name = "COUNT", default_value_t = 25)] pub in_peers: u32, /// Maximum number of inbound light nodes peers. - #[arg(long, value_name = "COUNT", default_value = "100")] + #[arg(long, value_name = "COUNT", default_value_t = 100)] pub in_peers_light: u32, /// Disable mDNS discovery. @@ -103,7 +103,7 @@ pub struct NetworkParams { /// /// This allows downloading announced blocks from multiple peers. Decrease to save /// traffic and risk increased latency. - #[arg(long, value_name = "COUNT", default_value = "5")] + #[arg(long, value_name = "COUNT", default_value_t = 5)] pub max_parallel_downloads: u32, #[allow(missing_docs)] @@ -139,7 +139,7 @@ pub struct NetworkParams { long, value_enum, value_name = "SYNC_MODE", - default_value = "full", + default_value_t = SyncMode::Full, ignore_case = true, verbatim_doc_comment )] diff --git a/client/cli/src/params/node_key_params.rs b/client/cli/src/params/node_key_params.rs index e7e2f31f1b1ff..2346455c26a37 100644 --- a/client/cli/src/params/node_key_params.rs +++ b/client/cli/src/params/node_key_params.rs @@ -66,7 +66,7 @@ pub struct NodeKeyParams { /// /// The node's secret key determines the corresponding public key and hence the /// node's peer ID in the context of libp2p. - #[arg(long, value_name = "TYPE", value_enum, ignore_case = true, default_value = "ed25519")] + #[arg(long, value_name = "TYPE", value_enum, ignore_case = true, default_value_t = NodeKeyType::Ed25519)] pub node_key_type: NodeKeyType, /// The file from which to read the node's secret key to use for libp2p networking. diff --git a/client/cli/src/params/offchain_worker_params.rs b/client/cli/src/params/offchain_worker_params.rs index be92fa4004cff..8cff48fad600c 100644 --- a/client/cli/src/params/offchain_worker_params.rs +++ b/client/cli/src/params/offchain_worker_params.rs @@ -40,7 +40,7 @@ pub struct OffchainWorkerParams { value_name = "ENABLED", value_enum, ignore_case = true, - default_value = "when-validating" + default_value_t = OffchainWorkerEnabled::WhenValidating )] pub enabled: OffchainWorkerEnabled, diff --git a/client/cli/src/params/shared_params.rs b/client/cli/src/params/shared_params.rs index 5ffa73229e1bc..cf24befc9248c 100644 --- a/client/cli/src/params/shared_params.rs +++ b/client/cli/src/params/shared_params.rs @@ -76,7 +76,7 @@ pub struct SharedParams { pub tracing_targets: Option, /// Receiver to process tracing messages. - #[arg(long, value_name = "RECEIVER", value_enum, ignore_case = true, default_value = "log")] + #[arg(long, value_name = "RECEIVER", value_enum, ignore_case = true, default_value_t = TracingReceiver::Log)] pub tracing_receiver: TracingReceiver, } diff --git a/client/cli/src/params/transaction_pool_params.rs b/client/cli/src/params/transaction_pool_params.rs index ed03533aedbb6..6b3a2d8a97a01 100644 --- a/client/cli/src/params/transaction_pool_params.rs +++ b/client/cli/src/params/transaction_pool_params.rs @@ -23,11 +23,11 @@ use sc_service::config::TransactionPoolOptions; #[derive(Debug, Clone, Args)] pub struct TransactionPoolParams { /// Maximum number of transactions in the transaction pool. - #[arg(long, value_name = "COUNT", default_value = "8192")] + #[arg(long, value_name = "COUNT", default_value_t = 8192)] pub pool_limit: usize, /// Maximum number of kilobytes of all transactions stored in the pool. - #[arg(long, value_name = "COUNT", default_value = "20480")] + #[arg(long, value_name = "COUNT", default_value_t = 20480)] pub pool_kbytes: usize, /// How long a transaction is banned for, if it is considered invalid. Defaults to 1800s. diff --git a/primitives/storage/src/lib.rs b/primitives/storage/src/lib.rs index 9c046bf9d2dd1..79c1012196bde 100644 --- a/primitives/storage/src/lib.rs +++ b/primitives/storage/src/lib.rs @@ -19,6 +19,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +use core::fmt::Display; + #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_debug_derive::RuntimeDebug; @@ -412,6 +414,15 @@ pub enum StateVersion { V1 = 1, } +impl Display for StateVersion { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + StateVersion::V0 => f.write_str("0"), + StateVersion::V1 => f.write_str("1"), + } + } +} + impl Default for StateVersion { fn default() -> Self { StateVersion::V1 diff --git a/utils/frame/benchmarking-cli/src/block/bench.rs b/utils/frame/benchmarking-cli/src/block/bench.rs index f3f85967153c5..318c58de8a553 100644 --- a/utils/frame/benchmarking-cli/src/block/bench.rs +++ b/utils/frame/benchmarking-cli/src/block/bench.rs @@ -51,7 +51,7 @@ pub struct BenchmarkParams { pub to: u32, /// Number of times that the benchmark should be repeated for each block. - #[arg(long, default_value = "10")] + #[arg(long, default_value_t = 10)] pub repeat: u32, } diff --git a/utils/frame/benchmarking-cli/src/extrinsic/bench.rs b/utils/frame/benchmarking-cli/src/extrinsic/bench.rs index 444b67ae2c5ed..2a86c10e7ad27 100644 --- a/utils/frame/benchmarking-cli/src/extrinsic/bench.rs +++ b/utils/frame/benchmarking-cli/src/extrinsic/bench.rs @@ -43,11 +43,11 @@ use crate::shared::{StatSelect, Stats}; #[derive(Debug, Default, Serialize, Clone, PartialEq, Args)] pub struct BenchmarkParams { /// Rounds of warmups before measuring. - #[arg(long, default_value = "10")] + #[arg(long, default_value_t = 10)] pub warmup: u32, /// How many times the benchmark should be repeated. - #[arg(long, default_value = "100")] + #[arg(long, default_value_t = 100)] pub repeat: u32, /// Maximal number of extrinsics that should be put into a block. diff --git a/utils/frame/benchmarking-cli/src/machine/mod.rs b/utils/frame/benchmarking-cli/src/machine/mod.rs index 0a23be21bfabc..a19db671f3cd1 100644 --- a/utils/frame/benchmarking-cli/src/machine/mod.rs +++ b/utils/frame/benchmarking-cli/src/machine/mod.rs @@ -60,23 +60,23 @@ pub struct MachineCmd { /// /// 10% means that the test would pass even when only 90% score was archived. /// Can be used to mitigate outliers of the benchmarks. - #[arg(long, default_value = "10.0", value_name = "PERCENT")] + #[arg(long, default_value_t = 10.0, value_name = "PERCENT")] pub tolerance: f64, /// Time limit for the verification benchmark. - #[arg(long, default_value = "5.0", value_name = "SECONDS")] + #[arg(long, default_value_t = 5.0, value_name = "SECONDS")] pub verify_duration: f32, /// Time limit for the hash function benchmark. - #[arg(long, default_value = "5.0", value_name = "SECONDS")] + #[arg(long, default_value_t = 5.0, value_name = "SECONDS")] pub hash_duration: f32, /// Time limit for the memory benchmark. - #[arg(long, default_value = "5.0", value_name = "SECONDS")] + #[arg(long, default_value_t = 5.0, value_name = "SECONDS")] pub memory_duration: f32, /// Time limit for each disk benchmark. - #[arg(long, default_value = "5.0", value_name = "SECONDS")] + #[arg(long, default_value_t = 5.0, value_name = "SECONDS")] pub disk_duration: f32, } diff --git a/utils/frame/benchmarking-cli/src/pallet/mod.rs b/utils/frame/benchmarking-cli/src/pallet/mod.rs index 13bf6cdc2de9a..b10f531bc0aed 100644 --- a/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -43,7 +43,7 @@ pub struct PalletCmd { pub extrinsic: Option, /// Select how many samples we should take across the variable components. - #[arg(short, long, default_value = "2")] + #[arg(short, long, default_value_t = 2)] pub steps: u32, /// Indicates lowest values for each of the component ranges. @@ -55,13 +55,13 @@ pub struct PalletCmd { pub highest_range_values: Vec, /// Select how many repetitions of this benchmark should run from within the wasm. - #[arg(short, long, default_value = "1")] + #[arg(short, long, default_value_t = 1)] pub repeat: u32, /// Select how many repetitions of this benchmark should run from the client. /// /// NOTE: Using this alone may give slower results, but will afford you maximum Wasm memory. - #[arg(long, default_value = "1")] + #[arg(long, default_value_t = 1)] pub external_repeat: u32, /// Print the raw results in JSON format. @@ -135,7 +135,7 @@ pub struct PalletCmd { value_name = "METHOD", value_enum, ignore_case = true, - default_value = DEFAULT_WASM_EXECUTION_METHOD, + default_value_t = DEFAULT_WASM_EXECUTION_METHOD, )] pub wasm_method: WasmExecutionMethod, @@ -151,7 +151,7 @@ pub struct PalletCmd { pub wasmtime_instantiation_strategy: WasmtimeInstantiationStrategy, /// Limit the memory the database cache can use. - #[arg(long = "db-cache", value_name = "MiB", default_value = "1024")] + #[arg(long = "db-cache", value_name = "MiB", default_value_t = 1024)] pub database_cache_size: u32, /// List the benchmarks that match your query rather than running them. diff --git a/utils/frame/benchmarking-cli/src/shared/weight_params.rs b/utils/frame/benchmarking-cli/src/shared/weight_params.rs index 7532815035959..030bbfa00d468 100644 --- a/utils/frame/benchmarking-cli/src/shared/weight_params.rs +++ b/utils/frame/benchmarking-cli/src/shared/weight_params.rs @@ -41,13 +41,13 @@ pub struct WeightParams { /// Multiply the resulting weight with the given factor. Must be positive. /// /// Is applied before `weight_add`. - #[arg(long = "mul", default_value = "1")] + #[arg(long = "mul", default_value_t = 1.0)] pub weight_mul: f64, /// Add the given offset to the resulting weight. /// /// Is applied after `weight_mul`. - #[arg(long = "add", default_value = "0")] + #[arg(long = "add", default_value_t = 0)] pub weight_add: u64, } diff --git a/utils/frame/benchmarking-cli/src/storage/cmd.rs b/utils/frame/benchmarking-cli/src/storage/cmd.rs index f61fe39dcb8ac..86041d9517de6 100644 --- a/utils/frame/benchmarking-cli/src/storage/cmd.rs +++ b/utils/frame/benchmarking-cli/src/storage/cmd.rs @@ -94,7 +94,7 @@ pub struct StorageParams { pub json_write_path: Option, /// Rounds of warmups before measuring. - #[arg(long, default_value = "1")] + #[arg(long, default_value_t = 1)] pub warmups: u32, /// The `StateVersion` to use. Substrate `--dev` should use `V1` and Polkadot `V0`. @@ -105,7 +105,7 @@ pub struct StorageParams { /// Trie cache size in bytes. /// /// Providing `0` will disable the cache. - #[arg(long, value_name = "Bytes", default_value = "67108864")] + #[arg(long, value_name = "Bytes", default_value_t = 67108864)] pub trie_cache_size: usize, /// Enable the Trie cache. diff --git a/utils/frame/generate-bags/node-runtime/src/main.rs b/utils/frame/generate-bags/node-runtime/src/main.rs index 66d5b0f51de2c..27e51b205f8ce 100644 --- a/utils/frame/generate-bags/node-runtime/src/main.rs +++ b/utils/frame/generate-bags/node-runtime/src/main.rs @@ -25,7 +25,7 @@ use std::path::PathBuf; // #[clap(author, version, about)] struct Opt { /// How many bags to generate. - #[arg(long, default_value = "200")] + #[arg(long, default_value_t = 200)] n_bags: usize, /// Where to write the output. diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index ec3053b7ed76b..0bf704dafdc0e 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -393,7 +393,7 @@ pub struct SharedParams { pub shared_params: sc_cli::SharedParams, /// The execution strategy that should be used. - #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true, default_value = "wasm")] + #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true, default_value_t = ExecutionStrategy::Wasm)] pub execution: ExecutionStrategy, /// Type of wasm execution used. @@ -402,7 +402,7 @@ pub struct SharedParams { value_name = "METHOD", value_enum, ignore_case = true, - default_value = DEFAULT_WASM_EXECUTION_METHOD, + default_value_t = DEFAULT_WASM_EXECUTION_METHOD, )] pub wasm_method: WasmExecutionMethod, @@ -427,7 +427,7 @@ pub struct SharedParams { pub no_spec_check_panic: bool, /// State version that is used by the chain. - #[arg(long, default_value = "1", value_parser = parse::state_version)] + #[arg(long, default_value_t = StateVersion::V1, value_parser = parse::state_version)] pub state_version: StateVersion, } From 4f614e767bf3fee4edc83ad66542649c4e5a0d3a Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Mon, 17 Oct 2022 16:33:11 +0200 Subject: [PATCH 20/20] Use 1.. instead of 0.. --- client/cli/src/params/network_params.rs | 8 ++++---- client/cli/src/params/shared_params.rs | 2 +- utils/frame/try-runtime/cli/src/lib.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/cli/src/params/network_params.rs b/client/cli/src/params/network_params.rs index 1bd4109710bb4..39f98b3573933 100644 --- a/client/cli/src/params/network_params.rs +++ b/client/cli/src/params/network_params.rs @@ -33,11 +33,11 @@ use std::{borrow::Cow, path::PathBuf}; #[derive(Debug, Clone, Args)] pub struct NetworkParams { /// Specify a list of bootnodes. - #[arg(long, value_name = "ADDR", num_args = 0..)] + #[arg(long, value_name = "ADDR", num_args = 1..)] pub bootnodes: Vec, /// Specify a list of reserved node addresses. - #[arg(long, value_name = "ADDR", num_args = 0..)] + #[arg(long, value_name = "ADDR", num_args = 1..)] pub reserved_nodes: Vec, /// Whether to only synchronize the chain with reserved nodes. @@ -53,7 +53,7 @@ pub struct NetworkParams { /// The public address that other nodes will use to connect to it. /// This can be used if there's a proxy in front of this node. - #[arg(long, value_name = "PUBLIC_ADDR", num_args = 0..)] + #[arg(long, value_name = "PUBLIC_ADDR", num_args = 1..)] pub public_addr: Vec, /// Listen on this multiaddress. @@ -61,7 +61,7 @@ pub struct NetworkParams { /// By default: /// If `--validator` is passed: `/ip4/0.0.0.0/tcp/` and `/ip6/[::]/tcp/`. /// Otherwise: `/ip4/0.0.0.0/tcp//ws` and `/ip6/[::]/tcp//ws`. - #[arg(long, value_name = "LISTEN_ADDR", num_args = 0..)] + #[arg(long, value_name = "LISTEN_ADDR", num_args = 1..)] pub listen_addr: Vec, /// Specify p2p protocol TCP port. diff --git a/client/cli/src/params/shared_params.rs b/client/cli/src/params/shared_params.rs index cf24befc9248c..6c03ac2c4ec23 100644 --- a/client/cli/src/params/shared_params.rs +++ b/client/cli/src/params/shared_params.rs @@ -46,7 +46,7 @@ pub struct SharedParams { /// /// Log levels (least to most verbose) are error, warn, info, debug, and trace. /// By default, all targets log `info`. The global log level can be set with -l. - #[arg(short = 'l', long, value_name = "LOG_PATTERN", num_args = 0..)] + #[arg(short = 'l', long, value_name = "LOG_PATTERN", num_args = 1..)] pub log: Vec, /// Enable detailed log output. diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index 0bf704dafdc0e..9034f356a9f67 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -481,7 +481,7 @@ pub enum State { /// A pallet to scrape. Can be provided multiple times. If empty, entire chain state will /// be scraped. - #[arg(short, long, num_args = 0..)] + #[arg(short, long, num_args = 1..)] pallet: Vec, /// Fetch the child-keys as well.