diff --git a/Cargo.lock b/Cargo.lock index 01c581e2f04..f2a8523d912 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5155,7 +5155,7 @@ dependencies = [ "base64 0.13.1", "candid", "chrono", - "clap 3.2.25", + "clap 4.5.19", "cycles-minting-canister", "futures", "hex", @@ -5391,7 +5391,7 @@ version = "0.9.0" dependencies = [ "anyhow", "chrono", - "clap 3.2.25", + "clap 4.5.19", "ic-config", "ic-crypto-utils-threshold-sig-der", "ic-logger", @@ -5676,7 +5676,7 @@ dependencies = [ "bitcoin 0.28.2", "bitcoincore-rpc", "bitcoind", - "clap 3.2.25", + "clap 4.5.19", "criterion", "futures", "hashlink", @@ -8372,7 +8372,7 @@ version = "0.1.0" dependencies = [ "async-stream", "byte-unit", - "clap 3.2.25", + "clap 4.5.19", "futures", "http 1.1.0", "http-body-util", @@ -9103,7 +9103,6 @@ dependencies = [ "candid", "chrono", "ciborium", - "clap 3.2.25", "dfn_protobuf", "ic-agent", "ic-certification 0.9.0", @@ -10218,7 +10217,7 @@ dependencies = [ name = "ic-nns-inspector" version = "0.1.0" dependencies = [ - "clap 3.2.25", + "clap 4.5.19", "csv", "hex", "ic-base-types", @@ -10497,7 +10496,7 @@ dependencies = [ "anyhow", "assert_matches", "base64 0.13.1", - "clap 3.2.25", + "clap 4.5.19", "fs_extra", "ic-config", "ic-crypto-node-key-generation", @@ -10629,7 +10628,7 @@ name = "ic-recovery" version = "0.1.0" dependencies = [ "base64 0.13.1", - "clap 3.2.25", + "clap 4.5.19", "futures", "hex", "ic-artifact-pool", @@ -10679,7 +10678,7 @@ version = "0.9.0" dependencies = [ "anyhow", "base64 0.13.1", - "clap 3.2.25", + "clap 4.5.19", "ic-base-types", "ic-crypto-sha2", "ic-crypto-utils-threshold-sig-der", @@ -10894,7 +10893,7 @@ dependencies = [ name = "ic-registry-replicator" version = "0.1.0" dependencies = [ - "clap 3.2.25", + "clap 4.5.19", "ic-config", "ic-crypto-utils-threshold-sig-der", "ic-http-endpoints-metrics", @@ -10979,7 +10978,7 @@ name = "ic-replay" version = "0.9.0" dependencies = [ "candid", - "clap 3.2.25", + "clap 4.5.19", "hex", "ic-artifact-pool", "ic-canister-client", @@ -11032,7 +11031,7 @@ version = "0.9.0" dependencies = [ "assert_cmd", "canister-test", - "clap 3.2.25", + "clap 4.5.19", "criterion", "hex", "ic-artifact-pool", @@ -11290,7 +11289,7 @@ dependencies = [ "async-trait", "base64 0.13.1", "candid", - "clap 3.2.25", + "clap 4.5.19", "dfn_candid", "dfn_protobuf", "futures", @@ -11534,7 +11533,7 @@ dependencies = [ "build-info-build", "candid", "candid_parser", - "clap 3.2.25", + "clap 4.5.19", "comparable", "futures", "hex", @@ -11995,7 +11994,7 @@ name = "ic-starter" version = "0.9.0" dependencies = [ "anyhow", - "clap 3.2.25", + "clap 4.5.19", "ic-config", "ic-logger", "ic-management-canister-types", @@ -12047,7 +12046,7 @@ version = "0.9.0" dependencies = [ "candid", "ciborium", - "clap 3.2.25", + "clap 4.5.19", "hex", "ic-artifact-pool", "ic-base-types", @@ -12219,7 +12218,7 @@ dependencies = [ name = "ic-state-tool" version = "0.9.0" dependencies = [ - "clap 3.2.25", + "clap 4.5.19", "hex", "ic-config", "ic-logger", @@ -12243,7 +12242,7 @@ dependencies = [ name = "ic-subnet-splitting" version = "0.1.0" dependencies = [ - "clap 3.2.25", + "clap 4.5.19", "hex", "ic-agent", "ic-base-types", @@ -12339,7 +12338,7 @@ dependencies = [ "candid", "canister-test", "chrono", - "clap 3.2.25", + "clap 4.5.19", "crossbeam-channel", "cycles-minting-canister", "deterministic_ips", @@ -14416,7 +14415,7 @@ checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" name = "launch-single-vm" version = "0.1.0" dependencies = [ - "clap 3.2.25", + "clap 4.5.19", "ic-prep", "ic-registry-subnet-type", "ic-system-test-driver", @@ -16012,7 +16011,7 @@ dependencies = [ "async-trait", "backoff", "candid", - "clap 3.2.25", + "clap 4.5.19", "exec", "get_if_addrs", "hex", @@ -16651,7 +16650,7 @@ dependencies = [ "bitcoincore-rpc", "bytes", "candid", - "clap 3.2.25", + "clap 4.5.19", "ctrlc", "flate2", "form_urlencoded", @@ -19921,7 +19920,6 @@ dependencies = [ "certificate_orchestrator_interface", "chacha20poly1305", "chrono", - "clap 3.2.25", "crossbeam-channel", "cycles-minting-canister", "deterministic_ips", @@ -21123,7 +21121,7 @@ dependencies = [ name = "vsock_guest" version = "1.0.0" dependencies = [ - "clap 3.2.25", + "clap 4.5.19", "vsock_lib", ] diff --git a/rs/backup/BUILD.bazel b/rs/backup/BUILD.bazel index 4e3547e9e0f..a792b7b5e34 100644 --- a/rs/backup/BUILD.bazel +++ b/rs/backup/BUILD.bazel @@ -13,7 +13,7 @@ DEPENDENCIES = [ "//rs/types/types", "@crate_index//:anyhow", "@crate_index//:chrono", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:rand", "@crate_index//:reqwest", "@crate_index//:serde", diff --git a/rs/backup/Cargo.toml b/rs/backup/Cargo.toml index 06e810231e9..e884b62ddb2 100644 --- a/rs/backup/Cargo.toml +++ b/rs/backup/Cargo.toml @@ -9,7 +9,7 @@ documentation.workspace = true [dependencies] anyhow = { workspace = true } chrono = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } ic-config = { path = "../config" } ic-crypto-utils-threshold-sig-der = { path = "../crypto/utils/threshold_sig_der" } ic-logger = { path = "../monitoring/logger" } diff --git a/rs/backup/src/cmd.rs b/rs/backup/src/cmd.rs index a5a3e934a8f..d1756161996 100644 --- a/rs/backup/src/cmd.rs +++ b/rs/backup/src/cmd.rs @@ -2,6 +2,7 @@ use clap::Parser; use ic_types::{PrincipalId, SubnetId}; use std::path::PathBuf; +#[derive(Clone)] pub struct ClapSubnetId(pub SubnetId); impl std::str::FromStr for ClapSubnetId { diff --git a/rs/bitcoin/adapter/BUILD.bazel b/rs/bitcoin/adapter/BUILD.bazel index 72f0e621780..5345842df92 100644 --- a/rs/bitcoin/adapter/BUILD.bazel +++ b/rs/bitcoin/adapter/BUILD.bazel @@ -12,7 +12,7 @@ DEPENDENCIES = [ "//rs/monitoring/logger", "//rs/monitoring/metrics", "@crate_index//:bitcoin", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:futures", "@crate_index//:hashlink", "@crate_index//:hex", diff --git a/rs/bitcoin/adapter/Cargo.toml b/rs/bitcoin/adapter/Cargo.toml index faeb740c6a2..97e93ea5b2a 100644 --- a/rs/bitcoin/adapter/Cargo.toml +++ b/rs/bitcoin/adapter/Cargo.toml @@ -8,7 +8,7 @@ documentation.workspace = true [dependencies] bitcoin = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } futures = { workspace = true } hashlink = "0.8.0" hex = { workspace = true } diff --git a/rs/boundary_node/systemd_journal_gatewayd_shim/BUILD.bazel b/rs/boundary_node/systemd_journal_gatewayd_shim/BUILD.bazel index 9857d6cacb9..2112c729dc9 100644 --- a/rs/boundary_node/systemd_journal_gatewayd_shim/BUILD.bazel +++ b/rs/boundary_node/systemd_journal_gatewayd_shim/BUILD.bazel @@ -5,7 +5,7 @@ DEPENDENCIES = [ "//rs/async_utils", "@crate_index//:anyhow", "@crate_index//:axum", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:http", "@crate_index//:itertools", "@crate_index//:reqwest", diff --git a/rs/https_outcalls/adapter/BUILD.bazel b/rs/https_outcalls/adapter/BUILD.bazel index 421b11ca219..89e484705c1 100644 --- a/rs/https_outcalls/adapter/BUILD.bazel +++ b/rs/https_outcalls/adapter/BUILD.bazel @@ -10,7 +10,7 @@ DEPENDENCIES = [ "//rs/monitoring/logger", "//rs/monitoring/metrics", "@crate_index//:byte-unit", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:futures", "@crate_index//:http", "@crate_index//:http-body-util", diff --git a/rs/https_outcalls/adapter/Cargo.toml b/rs/https_outcalls/adapter/Cargo.toml index 9480853d4b4..578ef82680d 100644 --- a/rs/https_outcalls/adapter/Cargo.toml +++ b/rs/https_outcalls/adapter/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] byte-unit = "4.0.14" -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } futures = { workspace = true } http = { workspace = true } http-body-util = { workspace = true } diff --git a/rs/ic_os/dev_test_tools/launch-single-vm/BUILD.bazel b/rs/ic_os/dev_test_tools/launch-single-vm/BUILD.bazel index a5c2b7195be..9032bdbc028 100644 --- a/rs/ic_os/dev_test_tools/launch-single-vm/BUILD.bazel +++ b/rs/ic_os/dev_test_tools/launch-single-vm/BUILD.bazel @@ -8,7 +8,7 @@ DEPENDENCIES = [ "//rs/registry/subnet_type", "//rs/tests/driver:ic-system-test-driver", "//rs/types/types", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:reqwest", "@crate_index//:serde", "@crate_index//:slog", diff --git a/rs/ic_os/dev_test_tools/launch-single-vm/Cargo.toml b/rs/ic_os/dev_test_tools/launch-single-vm/Cargo.toml index fcbf27371a1..a77464636fb 100644 --- a/rs/ic_os/dev_test_tools/launch-single-vm/Cargo.toml +++ b/rs/ic_os/dev_test_tools/launch-single-vm/Cargo.toml @@ -11,7 +11,7 @@ ic-registry-subnet-type = { path = "../../../registry/subnet_type" } ic-system-test-driver = { path = "../../../tests/driver" } ic-types = { path = "../../../types/types" } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } reqwest = { workspace = true } serde = { workspace = true } slog-async = { workspace = true } diff --git a/rs/ic_os/nss_icos/BUILD.bazel b/rs/ic_os/nss_icos/BUILD.bazel index 27b6722ca3a..b7f91462795 100644 --- a/rs/ic_os/nss_icos/BUILD.bazel +++ b/rs/ic_os/nss_icos/BUILD.bazel @@ -5,7 +5,6 @@ package(default_visibility = ["//rs:ic-os-pkg"]) DEPENDENCIES = [ # Keep sorted. "@crate_index//:base64", - "@crate_index//:clap_3_2_25", "@crate_index//:lazy_static", "@crate_index//:libc", "@crate_index//:libnss", diff --git a/rs/ic_os/vsock/guest/BUILD.bazel b/rs/ic_os/vsock/guest/BUILD.bazel index 5f95eba8ef6..9139032dd70 100644 --- a/rs/ic_os/vsock/guest/BUILD.bazel +++ b/rs/ic_os/vsock/guest/BUILD.bazel @@ -5,7 +5,7 @@ package(default_visibility = ["//rs:ic-os-pkg"]) DEPENDENCIES = [ # Keep sorted. "//rs/ic_os/vsock/vsock_lib:vsock_lib", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", ] MACRO_DEPENDENCIES = [] diff --git a/rs/ic_os/vsock/guest/Cargo.toml b/rs/ic_os/vsock/guest/Cargo.toml index b9216ea37ab..0bdf47355c7 100644 --- a/rs/ic_os/vsock/guest/Cargo.toml +++ b/rs/ic_os/vsock/guest/Cargo.toml @@ -6,5 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [target.'cfg(target_os = "linux")'.dependencies] -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } vsock_lib = { path = "../vsock_lib" } diff --git a/rs/nns/inspector/BUILD.bazel b/rs/nns/inspector/BUILD.bazel index a17ae43b2e1..0ad7574ed85 100644 --- a/rs/nns/inspector/BUILD.bazel +++ b/rs/nns/inspector/BUILD.bazel @@ -11,7 +11,7 @@ DEPENDENCIES = [ "//rs/nns/gtc", "//rs/rust_canisters/stable_reader", "//rs/types/base_types", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:csv", "@crate_index//:hex", "@crate_index//:prost", diff --git a/rs/nns/inspector/Cargo.toml b/rs/nns/inspector/Cargo.toml index 3af2eb0af74..8d38ba9a6d9 100644 --- a/rs/nns/inspector/Cargo.toml +++ b/rs/nns/inspector/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } csv = "1.1" hex = { workspace = true } ic-base-types = { path = "../../types/base_types" } diff --git a/rs/nns/inspector/src/main.rs b/rs/nns/inspector/src/main.rs index c24aca3981a..18e40854ee4 100644 --- a/rs/nns/inspector/src/main.rs +++ b/rs/nns/inspector/src/main.rs @@ -27,14 +27,13 @@ use std::{ )] struct CliArgs { /// Path to stable the `canister_states` directory - #[clap(parse(from_os_str))] input: PathBuf, - #[clap(parse(from_os_str), default_value = ".")] + #[clap(default_value = ".")] output: PathBuf, /// The location of the "rs" directory. Used to find .proto files. - #[clap(long, parse(from_os_str), default_value = ".")] + #[clap(long, default_value = ".")] rs: PathBuf, } diff --git a/rs/orchestrator/BUILD.bazel b/rs/orchestrator/BUILD.bazel index 646a126e2c1..5a7e5bb5aab 100644 --- a/rs/orchestrator/BUILD.bazel +++ b/rs/orchestrator/BUILD.bazel @@ -46,7 +46,7 @@ rust_library( "//rs/types/types", "@crate_index//:backoff", "@crate_index//:candid", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:exec", "@crate_index//:get_if_addrs", "@crate_index//:hex", @@ -78,7 +78,7 @@ rust_binary( # Keep sorted. ":lib", "//rs/async_utils", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:tokio", ], ) diff --git a/rs/orchestrator/Cargo.toml b/rs/orchestrator/Cargo.toml index e93debbab6f..ee7d89eaa40 100644 --- a/rs/orchestrator/Cargo.toml +++ b/rs/orchestrator/Cargo.toml @@ -10,7 +10,7 @@ documentation.workspace = true async-trait = { workspace = true } backoff = { workspace = true } candid = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } exec = "0.3.1" get_if_addrs = "0.5.3" hex = { workspace = true } diff --git a/rs/orchestrator/registry_replicator/BUILD.bazel b/rs/orchestrator/registry_replicator/BUILD.bazel index 50205831fa2..70ccfc7b7ca 100644 --- a/rs/orchestrator/registry_replicator/BUILD.bazel +++ b/rs/orchestrator/registry_replicator/BUILD.bazel @@ -18,7 +18,7 @@ DEPENDENCIES = [ "//rs/registry/nns_data_provider", "//rs/registry/routing_table", "//rs/types/types", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:prometheus", "@crate_index//:prost", "@crate_index//:slog", diff --git a/rs/orchestrator/registry_replicator/Cargo.toml b/rs/orchestrator/registry_replicator/Cargo.toml index b20d71dde06..91c6ca8c0df 100644 --- a/rs/orchestrator/registry_replicator/Cargo.toml +++ b/rs/orchestrator/registry_replicator/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } ic-config = { path = "../../config" } ic-crypto-utils-threshold-sig-der = { path = "../../crypto/utils/threshold_sig_der" } ic-http-endpoints-metrics = { path = "../../http_endpoints/metrics" } diff --git a/rs/orchestrator/registry_replicator/src/args.rs b/rs/orchestrator/registry_replicator/src/args.rs index 4335e098243..5d67a374c03 100644 --- a/rs/orchestrator/registry_replicator/src/args.rs +++ b/rs/orchestrator/registry_replicator/src/args.rs @@ -27,7 +27,7 @@ pub struct RegistryReplicatorArgs { pub log_as_text: bool, /// The path to the NNS public key file - #[clap(long, parse(from_os_str))] + #[clap(long)] pub nns_pub_key_pem: PathBuf, /// Comma separated list of NNS URLs @@ -35,7 +35,7 @@ pub struct RegistryReplicatorArgs { pub nns_url: String, /// The registry local store path to be populated - #[clap(long, parse(from_os_str))] + #[clap(long)] pub local_store_path: PathBuf, /// If not set, the default listen addr (0.0.0.0:9092) diff --git a/rs/orchestrator/src/args.rs b/rs/orchestrator/src/args.rs index e149619afd4..3a208c444e8 100644 --- a/rs/orchestrator/src/args.rs +++ b/rs/orchestrator/src/args.rs @@ -16,21 +16,21 @@ use std::{ /// Arguments for the orchestrator binary. pub struct OrchestratorArgs { /// The directory where Orchestrator will store Replica binaries - #[clap(long, parse(from_os_str))] + #[clap(long)] pub(crate) replica_binary_dir: PathBuf, /// The directory where Orchestrator will store catch-up packages (CUPs) - #[clap(long, parse(from_os_str))] + #[clap(long)] pub(crate) cup_dir: PathBuf, /// The path to the Replica config file - #[clap(long, parse(from_os_str))] + #[clap(long)] pub(crate) replica_config_file: PathBuf, /// The path to the Replica binary location containing the following in case /// of guest OS deployment: version.txt, manageboot.sh, replica, /// install-upgrade.sh - #[clap(long, parse(from_os_str))] + #[clap(long)] pub(crate) ic_binary_directory: Option, /// If not set, the default listen addr (0.0.0.0:[`PROMETHEUS_HTTP_PORT`]) @@ -44,7 +44,7 @@ pub struct OrchestratorArgs { pub(crate) enable_provisional_registration: bool, /// The path to the version file. - #[clap(long, parse(from_os_str))] + #[clap(long)] pub(crate) version_file: PathBuf, /// Print the replica's current node ID. @@ -57,7 +57,7 @@ pub struct OrchestratorArgs { /// The path to directory that is dedicated to data specific to the orchstrator. /// If not provided, the relevant data are not persisted to the disk. - #[clap(long, parse(from_os_str))] + #[clap(long)] pub(crate) orchestrator_data_directory: PathBuf, } diff --git a/rs/pocket_ic_server/BUILD.bazel b/rs/pocket_ic_server/BUILD.bazel index aa1b51e50ab..199c6963178 100644 --- a/rs/pocket_ic_server/BUILD.bazel +++ b/rs/pocket_ic_server/BUILD.bazel @@ -48,7 +48,7 @@ LIB_DEPENDENCIES = [ "@crate_index//:bitcoin", "@crate_index//:bytes", "@crate_index//:candid", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:ctrlc", "@crate_index//:flate2", "@crate_index//:form_urlencoded", diff --git a/rs/pocket_ic_server/Cargo.toml b/rs/pocket_ic_server/Cargo.toml index 0f9fb4f9d78..8112a66ea06 100644 --- a/rs/pocket_ic_server/Cargo.toml +++ b/rs/pocket_ic_server/Cargo.toml @@ -15,7 +15,7 @@ base64 = { workspace = true } bitcoin = { version = "0.28.1", features = ["default", "use-serde", "rand"] } bytes = { workspace = true } candid = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } ctrlc = { version = "3.4.5", features = ["termination"] } flate2 = { workspace = true } form_urlencoded = "1" diff --git a/rs/prep/BUILD.bazel b/rs/prep/BUILD.bazel index 307c25dc8ae..1133b75ef10 100644 --- a/rs/prep/BUILD.bazel +++ b/rs/prep/BUILD.bazel @@ -30,7 +30,7 @@ DEPENDENCIES = [ "//rs/types/types", "@crate_index//:anyhow", "@crate_index//:base64", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:fs_extra", "@crate_index//:json5", "@crate_index//:maplit", diff --git a/rs/prep/Cargo.toml b/rs/prep/Cargo.toml index 4ac1caddd2d..5b0e2290cc6 100644 --- a/rs/prep/Cargo.toml +++ b/rs/prep/Cargo.toml @@ -9,7 +9,7 @@ documentation.workspace = true [dependencies] anyhow = { workspace = true } base64 = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } fs_extra = "1.2.0" ic-config = { path = "../config" } ic-limits = { path = "../limits" } diff --git a/rs/prep/src/bin/prep.rs b/rs/prep/src/bin/prep.rs index 1dc9fe6360b..860f0c7571f 100644 --- a/rs/prep/src/bin/prep.rs +++ b/rs/prep/src/bin/prep.rs @@ -3,7 +3,6 @@ use std::{ collections::{BTreeMap, BTreeSet}, - convert::TryFrom, fs, io::{self, BufRead}, path::{Path, PathBuf}, @@ -49,7 +48,7 @@ const REQUEST_TIMEOUT: Duration = Duration::from_secs(12); /// See the README.adoc file for more details. struct CliArgs { /// The version of the Replica being run - #[clap(long, parse(try_from_str = ReplicaVersion::try_from))] + #[clap(long)] pub replica_version: Option, /// The URL against which a HTTP GET request will return a release @@ -59,7 +58,7 @@ struct CliArgs { /// and release-package-sha256-hex are unspecified, the /// release-package-download-url will default to /// https://download.dfinity.systems/ic//guest-os/update-img/update-img.tar.zst - #[clap(long, parse(try_from_str = url::Url::parse))] + #[clap(long)] pub release_package_download_url: Option, /// The hex-formatted SHA-256 hash of the archive served by @@ -74,11 +73,11 @@ struct CliArgs { pub release_package_sha256_hex: Option, /// JSON5 node definition - #[clap(long = "node", group = "node_spec", multiple_values(true), parse(try_from_str = Node::from_json5_without_braces))] + #[clap(long = "node", group = "node_spec", num_args(1..), value_parser = Node::from_json5_without_braces)] pub nodes: Vec, /// Path to working directory for node states. - #[clap(long, parse(from_os_str))] + #[clap(long)] pub working_dir: PathBuf, /// Skip generating subnet records @@ -91,7 +90,7 @@ struct CliArgs { /// Reads a directory containing datacenter's DER keys and a "meta.json" /// file containing metainformation for each datacenter. - #[clap(long, parse(from_os_str))] + #[clap(long)] pub dc_pk_path: Option, /// Indicate whether each node operator entry is required to specify a file @@ -108,7 +107,7 @@ struct CliArgs { /// A json-file containing a list of whitelisted principal IDs. A /// whitelisted principal is allowed to create canisters on any subnet on /// the IC. - #[clap(long, parse(from_os_str))] + #[clap(long)] pub provisional_whitelist: Option, /// The Principal Id of the node operator that is used for all nodes created @@ -126,13 +125,13 @@ struct CliArgs { /// The path to the file which contains the initial set of SSH public keys /// to populate the registry with, to give "readonly" access to all the /// nodes. - #[clap(long, parse(from_os_str))] + #[clap(long)] pub ssh_readonly_access_file: Option, /// The path to the file which contains the initial set of SSH public keys /// to populate the registry with, to give "backup" access to all the /// nodes. - #[clap(long, parse(from_os_str))] + #[clap(long)] pub ssh_backup_access_file: Option, /// Maximum size of ingress message in bytes. diff --git a/rs/prep/src/bin/principal_id.rs b/rs/prep/src/bin/principal_id.rs index f00822c1403..800d58d26d3 100644 --- a/rs/prep/src/bin/principal_id.rs +++ b/rs/prep/src/bin/principal_id.rs @@ -1,4 +1,4 @@ -use clap::{ArgEnum, Parser}; +use clap::{Parser, ValueEnum}; use ic_types::PrincipalId; use std::{ env, @@ -11,7 +11,7 @@ use std::{ use x509_cert::der; // re-export of der crate use x509_cert::spki; // re-export of spki crate -#[derive(Clone, Debug, ArgEnum)] +#[derive(Clone, Debug, ValueEnum)] enum PemOrDer { Pem, Der, @@ -51,14 +51,14 @@ EXAMPLES: )] enum CliArgs { SelfSigned { - #[clap(short = 'i', long = "input", parse(from_os_str))] + #[clap(short = 'i', long = "input")] file: Option, - #[clap(arg_enum, short = 't', long = "type")] + #[clap(value_enum, short = 't', long = "type")] pem_or_der: Option, }, Raw { - #[clap(short = 'i', long = "input", parse(from_os_str))] + #[clap(short = 'i', long = "input")] file: Option, }, } diff --git a/rs/recovery/BUILD.bazel b/rs/recovery/BUILD.bazel index 5846e144a4c..1364ceed55c 100644 --- a/rs/recovery/BUILD.bazel +++ b/rs/recovery/BUILD.bazel @@ -25,7 +25,7 @@ DEPENDENCIES = [ "//rs/types/management_canister_types", "//rs/types/types", "@crate_index//:base64", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:futures", "@crate_index//:hex", "@crate_index//:prost", diff --git a/rs/recovery/Cargo.toml b/rs/recovery/Cargo.toml index 965606d01d8..dc86c0c9c78 100644 --- a/rs/recovery/Cargo.toml +++ b/rs/recovery/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] base64 = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true} futures = { workspace = true } hex = { workspace = true } ic-artifact-pool = { path = "../artifact_pool" } diff --git a/rs/recovery/src/app_subnet_recovery.rs b/rs/recovery/src/app_subnet_recovery.rs index 074dda4a460..2462ea9eede 100644 --- a/rs/recovery/src/app_subnet_recovery.rs +++ b/rs/recovery/src/app_subnet_recovery.rs @@ -97,22 +97,22 @@ pub enum StepType { #[clap(version = "1.0")] pub struct AppSubnetRecoveryArgs { /// Id of the broken subnet - #[clap(long, parse(try_from_str=crate::util::subnet_id_from_str))] + #[clap(long, value_parser=crate::util::subnet_id_from_str)] pub subnet_id: SubnetId, /// Replica version to upgrade the broken subnet to - #[clap(long, parse(try_from_str=::std::convert::TryFrom::try_from))] + #[clap(long)] pub upgrade_version: Option, /// URL of the upgrade image - #[clap(long, parse(try_from_str=::std::convert::TryFrom::try_from))] + #[clap(long)] pub upgrade_image_url: Option, /// SHA256 hash of the upgrade image - #[clap(long, parse(try_from_str=::std::convert::TryFrom::try_from))] + #[clap(long)] pub upgrade_image_hash: Option, - #[clap(long, multiple_values(true), parse(try_from_str=crate::util::node_id_from_str))] + #[clap(long, num_args(1..), value_parser=crate::util::node_id_from_str)] /// Replace the members of the given subnet with these nodes pub replacement_nodes: Option>, @@ -137,7 +137,7 @@ pub struct AppSubnetRecoveryArgs { pub upload_node: Option, /// Id of the chain key subnet used for resharing chain keys to the subnet to be recovered - #[clap(long, parse(try_from_str=crate::util::subnet_id_from_str))] + #[clap(long, value_parser=crate::util::subnet_id_from_str)] pub chain_key_subnet_id: Option, /// If present the tool will start execution for the provided step, skipping the initial ones diff --git a/rs/recovery/src/cmd.rs b/rs/recovery/src/cmd.rs index 8a2f77094d1..43fabcb13fb 100644 --- a/rs/recovery/src/cmd.rs +++ b/rs/recovery/src/cmd.rs @@ -35,15 +35,15 @@ pub struct RecoveryToolArgs { pub nns_url: Url, /// replica version of ic-admin binary - #[clap(long, parse(try_from_str=::std::convert::TryFrom::try_from))] + #[clap(long)] pub replica_version: Option, /// The directory to perform recovery in - #[clap(long, parse(from_os_str), default_value = "/var/lib/ic/data")] + #[clap(long, default_value = "/var/lib/ic/data")] pub dir: PathBuf, /// The path to a private key to be considered for SSH connections - #[clap(long, parse(from_os_str))] + #[clap(long)] pub key_file: Option, /// Flag to enter test mode diff --git a/rs/recovery/src/nns_recovery_failover_nodes.rs b/rs/recovery/src/nns_recovery_failover_nodes.rs index 4405fd1ceb2..6515130645b 100644 --- a/rs/recovery/src/nns_recovery_failover_nodes.rs +++ b/rs/recovery/src/nns_recovery_failover_nodes.rs @@ -45,11 +45,11 @@ pub enum StepType { #[clap(version = "1.0")] pub struct NNSRecoveryFailoverNodesArgs { /// Id of the broken subnet - #[clap(long, parse(try_from_str=crate::util::subnet_id_from_str))] + #[clap(long, value_parser=crate::util::subnet_id_from_str)] pub subnet_id: SubnetId, /// Replica version to start the new NNS with (has to be blessed by parent NNS) - #[clap(long, parse(try_from_str=::std::convert::TryFrom::try_from))] + #[clap(long)] pub replica_version: Option, #[clap(long)] @@ -84,7 +84,7 @@ pub struct NNSRecoveryFailoverNodesArgs { #[clap(long)] pub parent_nns_host_ip: Option, - #[clap(long, multiple_values(true), parse(try_from_str=crate::util::node_id_from_str))] + #[clap(long, num_args(1..), value_parser=crate::util::node_id_from_str)] /// Replace the members of the given subnet with these nodes pub replacement_nodes: Option>, diff --git a/rs/recovery/src/nns_recovery_same_nodes.rs b/rs/recovery/src/nns_recovery_same_nodes.rs index e931a3c4437..9b9972ddd97 100644 --- a/rs/recovery/src/nns_recovery_same_nodes.rs +++ b/rs/recovery/src/nns_recovery_same_nodes.rs @@ -42,11 +42,11 @@ pub enum StepType { #[clap(version = "1.0")] pub struct NNSRecoverySameNodesArgs { /// Id of the broken subnet - #[clap(long, parse(try_from_str=crate::util::subnet_id_from_str))] + #[clap(long, value_parser=crate::util::subnet_id_from_str)] pub subnet_id: SubnetId, /// Replica version to upgrade the broken subnet to - #[clap(long, parse(try_from_str=::std::convert::TryFrom::try_from))] + #[clap(long)] pub upgrade_version: Option, #[clap(long)] @@ -54,11 +54,11 @@ pub struct NNSRecoverySameNodesArgs { pub replay_until_height: Option, /// URL of the upgrade image - #[clap(long, parse(try_from_str=::std::convert::TryFrom::try_from))] + #[clap(long)] pub upgrade_image_url: Option, /// SHA256 hash of the upgrade image - #[clap(long, parse(try_from_str=::std::convert::TryFrom::try_from))] + #[clap(long)] pub upgrade_image_hash: Option, /// IP address of the node to download the subnet state from. Should be different to node used in nns-url. diff --git a/rs/recovery/subnet_splitting/BUILD.bazel b/rs/recovery/subnet_splitting/BUILD.bazel index 5e1465a4da5..7250b6d7f43 100644 --- a/rs/recovery/subnet_splitting/BUILD.bazel +++ b/rs/recovery/subnet_splitting/BUILD.bazel @@ -14,7 +14,7 @@ DEPENDENCIES = [ "//rs/state_tool:state_tool_lib", "//rs/types/base_types", "//rs/types/types", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:hex", "@crate_index//:ic-agent", "@crate_index//:serde", diff --git a/rs/recovery/subnet_splitting/Cargo.toml b/rs/recovery/subnet_splitting/Cargo.toml index 6ba6ab209ba..0fa338491d9 100644 --- a/rs/recovery/subnet_splitting/Cargo.toml +++ b/rs/recovery/subnet_splitting/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } hex = { workspace = true } ic-agent = { workspace = true } ic-base-types = { path = "../../types/base_types/" } diff --git a/rs/recovery/subnet_splitting/src/main.rs b/rs/recovery/subnet_splitting/src/main.rs index 018efa4486b..84777025b6e 100644 --- a/rs/recovery/subnet_splitting/src/main.rs +++ b/rs/recovery/subnet_splitting/src/main.rs @@ -28,15 +28,15 @@ struct SplitArgs { nns_url: Url, /// replica version of ic-admin binary - #[clap(long, parse(try_from_str=::std::convert::TryFrom::try_from))] + #[clap(long)] replica_version: Option, /// The directory to the subnet splitting in - #[clap(long, parse(from_os_str))] + #[clap(long)] dir: PathBuf, /// The path to a private key to be considered for SSH connections - #[clap(long, parse(from_os_str))] + #[clap(long)] key_file: Option, /// Flag to enter test mode @@ -54,24 +54,24 @@ struct SplitArgs { #[derive(Parser)] struct ValidateArgs { /// Path to the State Tree signed by the NNS - #[clap(long, parse(from_os_str))] + #[clap(long)] state_tree_path: PathBuf, /// (Optional) path to the NNS public key. If not set, the built-in public key is used. - #[clap(long, parse(from_os_str))] + #[clap(long)] nns_public_key_path: Option, /// Path to the original, pre-split, CUP retrieved from the Source Subnet. - #[clap(long, parse(from_os_str))] + #[clap(long)] cup_path: PathBuf, /// Path to the original, pre-split, state manifest computed from the state on the Source /// Subnet. - #[clap(long, parse(from_os_str))] + #[clap(long)] state_manifest_path: PathBuf, /// SubnetId of the subnet being split. - #[clap(long, parse(try_from_str=ic_recovery::util::subnet_id_from_str))] + #[clap(long, value_parser=ic_recovery::util::subnet_id_from_str)] source_subnet_id: SubnetId, } diff --git a/rs/recovery/subnet_splitting/src/subnet_splitting.rs b/rs/recovery/subnet_splitting/src/subnet_splitting.rs index 80ff2ec1324..f20defd9a7f 100644 --- a/rs/recovery/subnet_splitting/src/subnet_splitting.rs +++ b/rs/recovery/subnet_splitting/src/subnet_splitting.rs @@ -82,11 +82,11 @@ pub enum StepType { #[clap(version = "1.0")] pub struct SubnetSplittingArgs { /// Id of the subnet whose state will be split. - #[clap(long, parse(try_from_str=ic_recovery::util::subnet_id_from_str))] + #[clap(long, value_parser=ic_recovery::util::subnet_id_from_str)] pub source_subnet_id: SubnetId, /// Id of the destination subnet. - #[clap(long, parse(try_from_str=ic_recovery::util::subnet_id_from_str))] + #[clap(long, value_parser=ic_recovery::util::subnet_id_from_str)] pub destination_subnet_id: SubnetId, /// Public ssh key to be deployed to the subnet for read only access. @@ -115,7 +115,7 @@ pub struct SubnetSplittingArgs { pub next_step: Option, /// The canister ID ranges to be moved to the destination subnet. - #[clap(long, multiple_values(true), required = true)] + #[clap(long, num_args(1..), required = true)] pub canister_id_ranges_to_move: Vec, } diff --git a/rs/registry/admin/BUILD.bazel b/rs/registry/admin/BUILD.bazel index a28b632cadc..b4729122aeb 100644 --- a/rs/registry/admin/BUILD.bazel +++ b/rs/registry/admin/BUILD.bazel @@ -48,7 +48,7 @@ DEPENDENCIES = [ "@crate_index//:base64", "@crate_index//:candid", "@crate_index//:chrono", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:futures", "@crate_index//:hex", "@crate_index//:ic-btc-interface", diff --git a/rs/registry/admin/Cargo.toml b/rs/registry/admin/Cargo.toml index 33d22692212..055a990025b 100644 --- a/rs/registry/admin/Cargo.toml +++ b/rs/registry/admin/Cargo.toml @@ -12,7 +12,7 @@ async-trait = { workspace = true } base64 = { workspace = true } candid = { workspace = true } chrono = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } cycles-minting-canister = { path = "../../nns/cmc" } futures = { workspace = true } hex = { workspace = true } diff --git a/rs/registry/admin/src/create_subnet.rs b/rs/registry/admin/src/create_subnet.rs index 005aa07b066..8ff058d9a93 100644 --- a/rs/registry/admin/src/create_subnet.rs +++ b/rs/registry/admin/src/create_subnet.rs @@ -28,7 +28,7 @@ pub(crate) struct ProposeToCreateSubnetCmd { /// Obsolete. Does nothing. Exists for compatibility with legacy scripts. subnet_handler_id: Option, - #[clap(name = "NODE_ID", multiple_values(true), required = true)] + #[clap(name = "NODE_ID", num_args(1..), required = true)] /// The node IDs of the nodes that will be part of the new subnet. pub node_ids: Vec, @@ -58,7 +58,7 @@ pub(crate) struct ProposeToCreateSubnetCmd { /// propagation. pub initial_notary_delay_millis: Option, - #[clap(long, parse(try_from_str = ReplicaVersion::try_from))] + #[clap(long)] /// ID of the Replica version to run. pub replica_version_id: Option, @@ -128,11 +128,11 @@ pub(crate) struct ProposeToCreateSubnetCmd { /// The list of public keys whose owners have "readonly" SSH access to all /// replicas on this subnet. - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] ssh_readonly_access: Vec, /// The list of public keys whose owners have "backup" SSH access to nodes /// on the NNS subnet. - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] ssh_backup_access: Vec, /// The maximum number of canisters that are allowed to be created in this diff --git a/rs/registry/admin/src/main.rs b/rs/registry/admin/src/main.rs index 61a14d88861..b7f5df3e0c9 100644 --- a/rs/registry/admin/src/main.rs +++ b/rs/registry/admin/src/main.rs @@ -3,7 +3,7 @@ use crate::helpers::*; use anyhow::anyhow; use async_trait::async_trait; use candid::{CandidType, Decode, Encode, Principal}; -use clap::{Args, Parser}; +use clap::{Args, Parser, ValueEnum}; use create_subnet::ProposeToCreateSubnetCmd; use cycles_minting_canister::{ ChangeSubnetTypeAssignmentArgs, SetAuthorizedSubnetworkListArgs, SubnetListWithType, @@ -245,7 +245,7 @@ struct Opts { #[clap( long = "nns-public-key-pem-file", help = "PEM file to overwrite the mainnet NNS public key. Requires --verify-nns-responses.", - requires = "verify-nns-responses" + requires = "verify_nns_responses" )] nns_public_key_pem_file: Option, @@ -259,8 +259,8 @@ struct Opts { } /// List of sub-commands accepted by `ic-admin`. -#[derive(Parser)] #[allow(clippy::large_enum_variant)] +#[derive(clap::Subcommand)] enum SubCommand { /// Get the last version of a node's public key from the registry. GetPublicKey(GetPublicKeyCmd), @@ -460,7 +460,7 @@ enum SubCommand { } /// Indicates whether a value should be added or removed. -#[derive(Parser)] +#[derive(Clone, ValueEnum)] enum AddOrRemove { /// Whether the value should be added Add, @@ -511,11 +511,11 @@ struct ProposeToChangeSubnetMembershipCmd { /// The subnet to modify subnet: SubnetDescriptor, - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] /// The node IDs of the nodes that should be added to the subnet. pub node_ids_add: Vec, - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] /// The node IDs of the nodes that should be removed from the subnet. pub node_ids_remove: Vec, } @@ -612,7 +612,7 @@ struct ProposeToDeployGuestosToAllSubnetNodesCmd { #[derive(Parser, ProposalMetadata)] struct ProposeToRemoveNodeOperatorsCmd { /// List of principal ids of node operators to remove - #[clap(multiple_values(true))] + #[clap(num_args(1..))] node_operators_to_remove: Vec, } @@ -715,7 +715,7 @@ impl ProposalPayload struct ProposeToUpdateSshReadonlyAccessForAllUnassignedNodesCmd { /// The list of public keys whose owners have "readonly" SSH access to all /// unassigned nodes. - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] pub ssh_readonly_access: Vec, } @@ -876,12 +876,12 @@ struct ProposeToReviseElectedGuestssVersionsCmd { /// 'release_package_urls'. pub release_package_sha256_hex: Option, - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] /// The URLs against which an HTTP GET request will return a release /// package that corresponds to this version. pub release_package_urls: Vec, - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] /// The replica version ids to remove. pub replica_versions_to_unelect: Vec, } @@ -1182,7 +1182,7 @@ struct ProposeToUpdateCanisterSettingsCmd { canister_id: CanisterId, /// If set, it will update the canister's controllers to this value. - #[clap(long, multiple_values(true), group = "update_controllers")] + #[clap(long, num_args(1..), group = "update_controllers")] controllers: Option>, /// If set, it will remove all controllers of the canister. #[clap(long, group = "update_controllers")] @@ -1489,7 +1489,7 @@ struct ProposeToInsertSnsWasmUpgradePathEntriesCmd { /// '{"archive":"archive-B","governance":"gov-A","index":"index-A","ledger":"ledger-A","root":"root-A","swap":"swap-A"}' /// '{"archive":"archive-B","governance":"gov-C","index":"index-A","ledger":"ledger-A","root":"root-A","swap":"swap-A"}' /// and the path will be two step entries from the first to the second, then the second to the third. - #[clap(required(true), multiple_values(true))] + #[clap(required(true), num_args(1..))] pub versions: Vec, } @@ -1681,7 +1681,7 @@ struct ProposeToSetAuthorizedSubnetworksCmd { /// The list of subnets that `who` would be authorized to create subnets on. /// If `subnets` is `None`, then `who` is removed from the list of /// authorized users. - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] pub subnets: Option>, } @@ -2032,11 +2032,11 @@ struct ProposeToAddOrRemoveDataCentersCmd { /// Example: /// '{ "id": "AN1", "region": "us-west", "owner": "DC Corp", "gps": { /// "latitude": 37.774929, "longitude": -122.419416 } }' - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] pub data_centers_to_add: Vec, /// The IDs of data centers to remove - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] pub data_centers_to_remove: Vec, /// If true, skips printing out the `AddOrRemoveDataCentersProposalPayload` @@ -2405,7 +2405,7 @@ struct GetFirewallRulesetHashCmd { #[derive(Parser, ProposalMetadata)] struct ProposeToRemoveNodesCmd { /// The IDs of the nodes to remove. - #[clap(name = "NODE_ID", multiple_values(true), required = true)] + #[clap(name = "NODE_ID", num_args(1..), required = true)] pub node_ids: Vec, } @@ -2484,7 +2484,7 @@ struct VoteOnRootProposalToUpgradeGovernanceCanisterCmd { #[derive(Parser, ProposalMetadata)] struct ProposeToPrepareCanisterMigrationCmd { /// The list of canister ID ranges in migration. - #[clap(long, multiple_values(true), required = true)] + #[clap(long, num_args(1..), required = true)] canister_id_ranges: Vec, /// The source of the canister ID ranges. #[clap(long, required = true)] @@ -2524,7 +2524,7 @@ impl ProposalPayload for ProposeToPrepareCanist #[derive(Parser, ProposalMetadata)] struct ProposeToRerouteCanisterRangesCmd { /// The list of canister ID ranges to be rerouted. - #[clap(long, multiple_values(true), required = true)] + #[clap(long, num_args(1..), required = true)] canister_id_ranges: Vec, /// The source of the canister ID ranges. #[clap(long, required = true)] @@ -2564,10 +2564,10 @@ impl ProposalPayload for ProposeToRerouteCanisterR #[derive(Parser, ProposalMetadata)] struct ProposeToCompleteCanisterMigrationCmd { /// The list of canister ID ranges to be removed from canister migrations. - #[clap(long, multiple_values(true), required = true)] + #[clap(long, num_args(1..), required = true)] canister_id_ranges: Vec, /// The migration trace containing a list of subnet IDs. - #[clap(long, multiple_values(true), required = true)] + #[clap(long, num_args(1..), required = true)] migration_trace: Vec, } @@ -3142,12 +3142,12 @@ struct ProposeToReviseElectedHostosVersionsCmd { /// 'release_package_urls'. pub release_package_sha256_hex: Option, - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] /// The URLs against which an HTTP GET request will return a release /// package that corresponds to this version. pub release_package_urls: Vec, - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] /// The HostOS version ids to remove. pub hostos_versions_to_unelect: Vec, } @@ -3190,7 +3190,7 @@ struct ProposeToUpdateNodesHostosVersionCmd {} #[derive(Parser, ProposalMetadata)] struct ProposeToDeployHostosToSomeNodesCmd { /// The list of nodes on which to set the given HostosVersion - #[clap(name = "NODE_ID", multiple_values(true), required = true)] + #[clap(name = "NODE_ID", num_args(1..), required = true)] pub node_ids: Vec, #[clap(flatten)] @@ -3261,7 +3261,7 @@ impl ProposalPayload for ProposeToDeployHostosToSomeNod #[derive_common_proposal_fields] #[derive(Parser, ProposalMetadata)] struct ProposeToAddApiBoundaryNodesCmd { - #[clap(long, required = true, multiple_values(true), alias = "node-ids")] + #[clap(long, required = true, num_args(1..), alias = "node-ids")] /// The nodes to assign as an API Boundary Node nodes: Vec, @@ -3299,7 +3299,7 @@ impl ProposalPayload for ProposeToAddApiBoundaryNode #[derive_common_proposal_fields] #[derive(Parser, ProposalMetadata)] struct ProposeToRemoveApiBoundaryNodesCmd { - #[clap(long, required = true, multiple_values(true), alias = "node-ids")] + #[clap(long, required = true, num_args(1..), alias = "node-ids")] /// The set of API Boundary Nodes that should be returned to an unassigned state nodes: Vec, } @@ -3337,7 +3337,7 @@ struct ProposeToUpdateApiBoundaryNodesVersionCmd {} #[derive_common_proposal_fields] #[derive(Parser, ProposalMetadata)] struct ProposeToDeployGuestosToSomeApiBoundaryNodesCmd { - #[clap(long, required = true, multiple_values(true), alias = "node-ids")] + #[clap(long, required = true, num_args(1..), alias = "node-ids")] /// The set of API Boundary Nodes that should have their version updated nodes: Vec, diff --git a/rs/registry/admin/src/recover_subnet.rs b/rs/registry/admin/src/recover_subnet.rs index e2e6d219a91..e9cae5e5773 100644 --- a/rs/registry/admin/src/recover_subnet.rs +++ b/rs/registry/admin/src/recover_subnet.rs @@ -37,7 +37,7 @@ pub(crate) struct ProposeToUpdateRecoveryCupCmd { /// The hash of the state pub state_hash: String, - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] /// Replace the members of the given subnet with these nodes pub replacement_nodes: Option>, diff --git a/rs/registry/admin/src/update_subnet.rs b/rs/registry/admin/src/update_subnet.rs index 04261e7ee1e..b4fdc096f36 100644 --- a/rs/registry/admin/src/update_subnet.rs +++ b/rs/registry/admin/src/update_subnet.rs @@ -146,11 +146,11 @@ pub(crate) struct ProposeToUpdateSubnetCmd { /// The list of public keys whose owners have "readonly" SSH access to all /// replicas on this subnet. - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] ssh_readonly_access: Option>, /// The list of public keys whose owners have "backup" SSH access to nodes /// on the NNS subnet. - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] ssh_backup_access: Option>, /// If set, the created proposal will contain a desired override of that diff --git a/rs/registry/regedit/BUILD.bazel b/rs/registry/regedit/BUILD.bazel index 0e3572f6073..ebe655ba3ad 100644 --- a/rs/registry/regedit/BUILD.bazel +++ b/rs/registry/regedit/BUILD.bazel @@ -15,7 +15,7 @@ DEPENDENCIES = [ "//rs/types/types", "@crate_index//:anyhow", "@crate_index//:base64", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:prost", "@crate_index//:serde", "@crate_index//:serde_json", diff --git a/rs/registry/regedit/Cargo.toml b/rs/registry/regedit/Cargo.toml index 9d52df4d02e..8322f30510d 100644 --- a/rs/registry/regedit/Cargo.toml +++ b/rs/registry/regedit/Cargo.toml @@ -9,7 +9,7 @@ documentation.workspace = true [dependencies] anyhow = { workspace = true } base64 = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } ic-base-types = { path = "../../types/base_types" } ic-crypto-sha2 = { path = "../../crypto/sha2/" } ic-crypto-utils-threshold-sig-der = { path = "../../crypto/utils/threshold_sig_der" } diff --git a/rs/registry/regedit/src/args.rs b/rs/registry/regedit/src/args.rs index 0199f115eaf..0c2255d4a76 100644 --- a/rs/registry/regedit/src/args.rs +++ b/rs/registry/regedit/src/args.rs @@ -36,17 +36,15 @@ pub enum CommandArg { keys: Option, /// Path to the local store (may not be specified together with --url). - #[clap(parse(from_os_str))] local_store_path: PathBuf, }, CanisterToProto { /// Url to a node hosting the registry canister (may not be specified /// together with --local-store). - #[clap(long, parse(try_from_str = url::Url::parse))] + #[clap(long)] url: Url, /// Path to the local store (may not be specified together with --url). - #[clap(parse(from_os_str))] path: PathBuf, /// The registry version where the delta starts. (default: 0) @@ -60,7 +58,6 @@ pub enum CommandArg { /// Optional path to the threshold public key of the root subnet /// (a.k.a. NNS public key). One way to get this key is via /// "ic-admin --nns-url https://nns.ic0.app get-subnet-public-key" - #[clap(parse(from_os_str))] nns_public_key: Option, }, ShowDiff { @@ -70,11 +67,9 @@ pub enum CommandArg { version: Option, /// Path to the local store (may not be specified together with --url). - #[clap(parse(from_os_str))] local_store_path: PathBuf, /// Path to the local store (may not be specified together with --url). - #[clap(parse(from_os_str))] snapshot_file: PathBuf, }, ApplyUpdate { @@ -84,23 +79,21 @@ pub enum CommandArg { amend: bool, /// Path to the local store (may not be specified together with --url). - #[clap(parse(from_os_str))] local_store_path: PathBuf, /// Path to the local store (may not be specified together with --url). - #[clap(parse(from_os_str))] snapshot_file: PathBuf, }, CanisterSnapshot { /// Url to a node hosting the registry canister (may not be specified /// together with --local-store). - #[clap(long, parse(try_from_str = url::Url::parse))] + #[clap(long)] url: Url, /// Optional path to the threshold public key of the root subnet /// (a.k.a. NNS public key). One way to get this key is via /// "ic-admin --nns-url https://nns.ic0.app get-subnet-public-key" - #[clap(long, parse(from_os_str))] + #[clap(long)] nns_public_key: Option, /// The registry version of the snapshot. (default: latest available @@ -120,13 +113,12 @@ pub enum CommandArg { CanisterShowDiff { /// Url to a node hosting the registry canister (may not be specified /// together with --local-store). - #[clap(long, parse(try_from_str = url::Url::parse))] + #[clap(long)] url: Url, /// Optional path to the threshold public key of the root subnet /// (a.k.a. NNS public key). One way to get this key is via /// "ic-admin --nns-url https://nns.ic0.app get-subnet-public-key" - #[clap(parse(from_os_str))] nns_public_key: Option, /// The registry version of the snapshot. (default: latest available @@ -135,7 +127,6 @@ pub enum CommandArg { version: Option, /// Path to the local store (may not be specified together with --url). - #[clap(parse(from_os_str))] snapshot_file: PathBuf, }, } diff --git a/rs/replay/BUILD.bazel b/rs/replay/BUILD.bazel index f9edd6aa2e4..3e1ac174640 100644 --- a/rs/replay/BUILD.bazel +++ b/rs/replay/BUILD.bazel @@ -35,7 +35,7 @@ DEPENDENCIES = [ "//rs/state_manager", "//rs/types/types", "@crate_index//:candid", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:hex", "@crate_index//:prost", "@crate_index//:rand", diff --git a/rs/replay/Cargo.toml b/rs/replay/Cargo.toml index a0e5c07ee73..4397dbfaac0 100644 --- a/rs/replay/Cargo.toml +++ b/rs/replay/Cargo.toml @@ -8,7 +8,7 @@ documentation.workspace = true [dependencies] candid = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } hex = { workspace = true } ic-artifact-pool = { path = "../artifact_pool" } ic-canister-client = { path = "../canister_client" } diff --git a/rs/replay/src/cmd.rs b/rs/replay/src/cmd.rs index 4cfd9c305fc..b8d12069593 100644 --- a/rs/replay/src/cmd.rs +++ b/rs/replay/src/cmd.rs @@ -1,8 +1,9 @@ -use clap::Parser; +use clap::{Parser, Subcommand}; use ic_types::{CanisterId, PrincipalId, SubnetId}; use icp_ledger::AccountIdentifier; use std::path::PathBuf; +#[derive(Clone)] pub struct ClapSubnetId(pub SubnetId); impl std::str::FromStr for ClapSubnetId { @@ -41,7 +42,7 @@ pub struct ReplayToolArgs { pub replay_until_height: Option, } -#[derive(Clone, Parser)] +#[derive(Clone, Subcommand)] pub enum SubCommand { /// Add a new version of the replica binary to the registry. AddAndBlessReplicaVersion(AddAndBlessReplicaVersionCmd), diff --git a/rs/replica/BUILD.bazel b/rs/replica/BUILD.bazel index cdcd1ae6383..2eee559a680 100644 --- a/rs/replica/BUILD.bazel +++ b/rs/replica/BUILD.bazel @@ -37,7 +37,7 @@ DEPENDENCIES = [ "//rs/sys", "//rs/types/types", "//rs/xnet/payload_builder", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:hex", "@crate_index//:libc", "@crate_index//:nix", diff --git a/rs/replica/Cargo.toml b/rs/replica/Cargo.toml index 617a43c88f2..b0958cd82bc 100644 --- a/rs/replica/Cargo.toml +++ b/rs/replica/Cargo.toml @@ -7,7 +7,7 @@ description.workspace = true documentation.workspace = true [dependencies] -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } hex = { workspace = true } ic-artifact-pool = { path = "../artifact_pool" } ic-async-utils = { path = "../async_utils" } diff --git a/rs/replica/src/args.rs b/rs/replica/src/args.rs index 913d26b761e..963190c26a6 100644 --- a/rs/replica/src/args.rs +++ b/rs/replica/src/args.rs @@ -1,7 +1,6 @@ use clap::Parser; use ic_config::ConfigSource; use ic_types::ReplicaVersion; -use std::convert::TryFrom; use std::path::PathBuf; #[derive(Debug, Parser)] @@ -16,7 +15,7 @@ pub struct ReplicaArgs { pub print_sample_config: bool, /// The path to the Replica config file - #[clap(long, parse(from_os_str))] + #[clap(long)] pub config_file: Option, /// A string representation of the Replica config @@ -24,11 +23,11 @@ pub struct ReplicaArgs { pub config_literal: Option, /// A path to a CBOR-encoded catch-up package to seed the Replica with - #[clap(long, parse(from_os_str))] + #[clap(long)] pub catch_up_package: Option, /// The version of the Replica being run - #[clap(long, parse(try_from_str = ReplicaVersion::try_from))] + #[clap(long)] pub replica_version: ReplicaVersion, /// Force to use the given subnet ID. This is needed to upgrade NNS diff --git a/rs/replica/tests/cli.rs b/rs/replica/tests/cli.rs index 62de42137a0..5a642b81898 100644 --- a/rs/replica/tests/cli.rs +++ b/rs/replica/tests/cli.rs @@ -26,7 +26,7 @@ fn too_many_arguments_causes_exit_code_1() { .args(["arg1", "arg2"]) .assert() .stderr(predicate::str::starts_with( - "error: Found argument 'arg1' which wasn't expected", + "error: unexpected argument 'arg1' found", )) .failure(); } diff --git a/rs/rosetta-api/icp/BUILD.bazel b/rs/rosetta-api/icp/BUILD.bazel index f76717a1630..da51dfa29e6 100644 --- a/rs/rosetta-api/icp/BUILD.bazel +++ b/rs/rosetta-api/icp/BUILD.bazel @@ -36,7 +36,7 @@ DEPENDENCIES = [ "@crate_index//:anyhow", "@crate_index//:base64", "@crate_index//:candid", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:hex", "@crate_index//:ic-agent", "@crate_index//:lazy_static", diff --git a/rs/rosetta-api/icp/Cargo.toml b/rs/rosetta-api/icp/Cargo.toml index 443c25d68ac..baf8963db53 100644 --- a/rs/rosetta-api/icp/Cargo.toml +++ b/rs/rosetta-api/icp/Cargo.toml @@ -13,7 +13,7 @@ anyhow = { workspace = true } async-trait = { workspace = true } base64 = { workspace = true } candid = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } dfn_candid = { path = "../../rust_canisters/dfn_candid" } dfn_protobuf = { path = "../../rust_canisters/dfn_protobuf" } hex = { workspace = true } diff --git a/rs/rosetta-api/icp/ledger_canister_blocks_synchronizer/Cargo.toml b/rs/rosetta-api/icp/ledger_canister_blocks_synchronizer/Cargo.toml index 7c50b428b8e..70506dbe470 100644 --- a/rs/rosetta-api/icp/ledger_canister_blocks_synchronizer/Cargo.toml +++ b/rs/rosetta-api/icp/ledger_canister_blocks_synchronizer/Cargo.toml @@ -10,7 +10,6 @@ async-trait = { workspace = true } candid = { workspace = true } chrono = { workspace = true } ciborium = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } dfn_protobuf = { path = "../../../rust_canisters/dfn_protobuf" } ic-agent = { workspace = true } ic-certification = { path = "../../../certification" } diff --git a/rs/sns/governance/BUILD.bazel b/rs/sns/governance/BUILD.bazel index 16fa794b719..04f00fdf5db 100644 --- a/rs/sns/governance/BUILD.bazel +++ b/rs/sns/governance/BUILD.bazel @@ -42,7 +42,7 @@ DEPENDENCIES = [ "@crate_index//:base64", "@crate_index//:build-info", "@crate_index//:candid", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:comparable", "@crate_index//:futures", "@crate_index//:hex", diff --git a/rs/sns/governance/Cargo.toml b/rs/sns/governance/Cargo.toml index d2f81e9dfe3..7288725d902 100644 --- a/rs/sns/governance/Cargo.toml +++ b/rs/sns/governance/Cargo.toml @@ -31,7 +31,7 @@ build-info = { workspace = true } async-trait = { workspace = true } base64 = { workspace = true } candid = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } comparable = { version = "0.5", features = ["derive"] } hex = { workspace = true } futures = { workspace = true } diff --git a/rs/sns/governance/protobuf_generator/src/lib.rs b/rs/sns/governance/protobuf_generator/src/lib.rs index 0744a6d3284..24871f25267 100644 --- a/rs/sns/governance/protobuf_generator/src/lib.rs +++ b/rs/sns/governance/protobuf_generator/src/lib.rs @@ -38,7 +38,7 @@ pub fn generate_prost_files(proto: ProtoPaths<'_>, out: &Path) { // Misc Attributes config.type_attribute( "ic_sns_governance.pb.v1.NeuronPermissionType", - "#[derive(clap::ArgEnum)]", + "#[derive(clap::ValueEnum)]", ); config.type_attribute( "ic_sns_governance.pb.v1.NeuronId", diff --git a/rs/sns/governance/src/gen/ic_sns_governance.pb.v1.rs b/rs/sns/governance/src/gen/ic_sns_governance.pb.v1.rs index 5f3400f3e3f..a83b31c889c 100644 --- a/rs/sns/governance/src/gen/ic_sns_governance.pb.v1.rs +++ b/rs/sns/governance/src/gen/ic_sns_governance.pb.v1.rs @@ -3433,7 +3433,7 @@ pub struct Account { candid::CandidType, candid::Deserialize, comparable::Comparable, - clap::ArgEnum, + clap::ValueEnum, strum_macros::EnumIter, Clone, Copy, diff --git a/rs/starter/BUILD.bazel b/rs/starter/BUILD.bazel index cc5c8c54ede..44a8c9f5ffd 100644 --- a/rs/starter/BUILD.bazel +++ b/rs/starter/BUILD.bazel @@ -17,7 +17,7 @@ DEPENDENCIES = [ "//rs/types/management_canister_types", "//rs/types/types", "@crate_index//:anyhow", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:serde", "@crate_index//:serde_json", "@crate_index//:slog", diff --git a/rs/starter/Cargo.toml b/rs/starter/Cargo.toml index 9c500f918ac..e28824a3d2d 100644 --- a/rs/starter/Cargo.toml +++ b/rs/starter/Cargo.toml @@ -10,7 +10,7 @@ documentation.workspace = true [dependencies] anyhow = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } ic-config = { path = "../config" } ic-logger = { path = "../monitoring/logger" } ic-management-canister-types = { path = "../types/management_canister_types" } diff --git a/rs/starter/src/main.rs b/rs/starter/src/main.rs index 4bc8603b1f6..7bec330565e 100644 --- a/rs/starter/src/main.rs +++ b/rs/starter/src/main.rs @@ -20,6 +20,7 @@ //! - serves metrics at localhost:18080 instead of dumping them at stdout use anyhow::Result; +use clap::builder::PossibleValuesParser; use clap::Parser; use ic_config::{ adapters::AdaptersConfig, @@ -216,11 +217,11 @@ struct CliArgs { /// expected that a config will be found for '--bin replica'. In other /// words, it is expected that the starter is invoked from the rs/ /// directory. - #[clap(long = "replica-path", parse(from_os_str))] + #[clap(long = "replica-path")] replica_path: Option, /// Version of the replica binary. - #[clap(long, parse(try_from_str = ReplicaVersion::try_from))] + #[clap(long)] replica_version: Option, /// Path to the cargo binary. Not optional because there is a default value. @@ -242,7 +243,7 @@ struct CliArgs { /// Path to the directory containing all state for this replica. (default: a /// temp directory that will be deleted immediately when the replica /// stops). - #[clap(long = "state-dir", parse(from_os_str))] + #[clap(long = "state-dir")] state_dir: Option, /// The http port of the public API. @@ -266,7 +267,7 @@ struct CliArgs { /// at start time. /// /// This argument is incompatible with --http-port. - #[clap(long = "http-port-file", parse(from_os_str))] + #[clap(long = "http-port-file")] http_port_file: Option, /// Arg to control whitelist for creating funds which is either set to "*" @@ -276,7 +277,7 @@ struct CliArgs { /// Run replica and ic-starter with the provided log level. Default is Warning #[clap(long = "log-level", - possible_values = &["critical", "error", "warning", "info", "debug", "trace"], + value_parser = PossibleValuesParser::new(["critical", "error", "warning", "info", "debug", "trace"]), ignore_case = true)] log_level: Option, @@ -308,12 +309,12 @@ struct CliArgs { /// The backend DB used by Consensus, can be rocksdb or lmdb. #[clap(long = "consensus-pool-backend", - possible_values = &["lmdb", "rocksdb"])] + value_parser = PossibleValuesParser::new(["lmdb", "rocksdb"]))] consensus_pool_backend: Option, /// Subnet features #[clap(long = "subnet-features", - possible_values = &[ + value_parser = PossibleValuesParser::new([ "canister_sandboxing", "http_requests", "bitcoin_testnet", @@ -325,8 +326,8 @@ struct CliArgs { "bitcoin_regtest", "bitcoin_regtest_syncing", "bitcoin_regtest_paused", - ], - multiple_values(true))] + ]), + num_args(1..))] subnet_features: Vec, /// Enable ecdsa signature by assigning the given key id a freshly generated key. @@ -340,7 +341,7 @@ struct CliArgs { /// Subnet type #[clap(long = "subnet-type", - possible_values = &["application", "verified_application", "system"])] + value_parser = PossibleValuesParser::new(["application", "verified_application", "system"]))] subnet_type: Option, /// Unix Domain Socket for Bitcoin testnet diff --git a/rs/state_machine_tests/BUILD.bazel b/rs/state_machine_tests/BUILD.bazel index 6dd4105f541..e89e69a4de0 100644 --- a/rs/state_machine_tests/BUILD.bazel +++ b/rs/state_machine_tests/BUILD.bazel @@ -92,7 +92,7 @@ BIN_DEPENDENCIES = [ "//rs/types/types", "@crate_index//:candid", "@crate_index//:ciborium", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:hex", "@crate_index//:ic-test-state-machine-client", "@crate_index//:serde", diff --git a/rs/state_machine_tests/Cargo.toml b/rs/state_machine_tests/Cargo.toml index 66881244e76..9024fc1a71b 100644 --- a/rs/state_machine_tests/Cargo.toml +++ b/rs/state_machine_tests/Cargo.toml @@ -11,7 +11,7 @@ documentation.workspace = true [dependencies] candid = { workspace = true } ciborium = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true} hex = { workspace = true } ic-artifact-pool = { path = "../artifact_pool" } ic-btc-adapter-client = { path = "../bitcoin/client" } diff --git a/rs/state_tool/BUILD.bazel b/rs/state_tool/BUILD.bazel index b37a4dcadd0..6e2d7bb6d86 100644 --- a/rs/state_tool/BUILD.bazel +++ b/rs/state_tool/BUILD.bazel @@ -14,7 +14,7 @@ DEPENDENCIES = [ "//rs/sys", "//rs/types/types", "//rs/utils", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:hex", "@crate_index//:prost", "@crate_index//:slog", diff --git a/rs/state_tool/Cargo.toml b/rs/state_tool/Cargo.toml index 54c360d1422..3fd5cf6527b 100644 --- a/rs/state_tool/Cargo.toml +++ b/rs/state_tool/Cargo.toml @@ -13,7 +13,7 @@ name = "state-tool" path = "src/main.rs" [dependencies] -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } hex = { workspace = true } ic-config = { path = "../config" } ic-logger = { path = "../monitoring/logger" } diff --git a/rs/state_tool/src/main.rs b/rs/state_tool/src/main.rs index 5c81943e5ac..d0b0d69774d 100644 --- a/rs/state_tool/src/main.rs +++ b/rs/state_tool/src/main.rs @@ -113,10 +113,10 @@ enum Opt { #[clap(long, required = true)] subnet_id: PrincipalId, /// Canister ID ranges to retain (assigned to the subnet in the routing table). - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] retain: Vec, /// Canister ID ranges to drop (assigned to other subnet in the routing table). - #[clap(long, multiple_values(true))] + #[clap(long, num_args(1..))] drop: Vec, /// New subnet's batch time (original subnet always retains its batch time). /// @@ -144,7 +144,7 @@ enum Opt { #[clap(long, required = true)] batch_time_nanos: u64, /// Canister ID ranges migrated to the new subnet. - #[clap(long, required = true, multiple_values(true))] + #[clap(long, required = true, num_args(1..))] migrated_ranges: Vec, }, } diff --git a/rs/tests/Cargo.toml b/rs/tests/Cargo.toml index 1aaeb7ad65b..d959d9fff33 100644 --- a/rs/tests/Cargo.toml +++ b/rs/tests/Cargo.toml @@ -22,7 +22,6 @@ canister-test = { path = "../rust_canisters/canister_test" } certificate_orchestrator_interface = { path = "../boundary_node/certificate_issuance/certificate_orchestrator_interface" } chacha20poly1305 = "0.10.0" chrono = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } crossbeam-channel = { workspace = true } cycles-minting-canister = { path = "../nns/cmc" } deterministic_ips = { path = "../ic_os/dev_test_tools/deterministic_ips" } diff --git a/rs/tests/driver/Cargo.toml b/rs/tests/driver/Cargo.toml index 5d0dfde5e77..6633f3082dd 100644 --- a/rs/tests/driver/Cargo.toml +++ b/rs/tests/driver/Cargo.toml @@ -16,7 +16,7 @@ bincode = { workspace = true } candid = { workspace = true } canister-test = { path = "../../rust_canisters/canister_test" } chrono = { workspace = true } -clap = { version = "3.2.25", features = ["derive"] } +clap = { workspace = true } crossbeam-channel = { workspace = true } cycles-minting-canister = { path = "../../nns/cmc" } deterministic_ips = { path = "../../ic_os/dev_test_tools/deterministic_ips" } diff --git a/rs/tests/httpbin-rs/BUILD.bazel b/rs/tests/httpbin-rs/BUILD.bazel index 2b93aa6fd19..f8b2d167a65 100644 --- a/rs/tests/httpbin-rs/BUILD.bazel +++ b/rs/tests/httpbin-rs/BUILD.bazel @@ -9,7 +9,7 @@ package(default_visibility = ["//rs:system-tests-pkg"]) DEPENDENCIES = [ # Keep sorted. "@crate_index//:axum", - "@crate_index//:clap_3_2_25", + "@crate_index//:clap", "@crate_index//:hyper", "@crate_index//:hyper-util", "@crate_index//:rustls", diff --git a/rs/types/types/src/replica_version.rs b/rs/types/types/src/replica_version.rs index b4e39e0a285..8f1af5c5bf1 100644 --- a/rs/types/types/src/replica_version.rs +++ b/rs/types/types/src/replica_version.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; use std::convert::TryFrom; use std::error::Error; use std::fmt; +use std::str::FromStr; #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Deserialize, Serialize)] pub struct ReplicaVersion { @@ -70,6 +71,14 @@ fn is_valid_version_symbol(c: char) -> bool { matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '.' | '_' | '-') } +impl FromStr for ReplicaVersion { + type Err = ReplicaVersionParseError; + + fn from_str(version_str: &str) -> Result { + ReplicaVersion::try_from(version_str) + } +} + impl TryFrom<&str> for ReplicaVersion { type Error = ReplicaVersionParseError;