From 45c3bb4c724487fc7e07d2b881a3b7057e4e5ec7 Mon Sep 17 00:00:00 2001 From: Filipe Azevedo Date: Tue, 30 Jan 2024 11:29:24 +0000 Subject: [PATCH] upgrade clap --- Cargo.lock | 134 +++++++++++++++++++++++++++----------- Cargo.toml | 1 + graph/Cargo.toml | 2 +- graph/examples/stress.rs | 2 +- node/Cargo.toml | 2 +- node/src/bin/manager.rs | 32 ++++----- node/src/opt.rs | 21 +++--- runtime/test/src/test.rs | 2 - store/postgres/Cargo.toml | 3 +- 9 files changed, 128 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6a900a74e61..835cef554c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,6 +72,54 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -486,42 +534,49 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.25" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ - "atty", - "bitflags 1.3.1", + "clap_builder", "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", "clap_lex", - "indexmap 1.9.3", - "once_cell", "strsim", - "termcolor", - "textwrap", ] [[package]] name = "clap_derive" -version = "3.2.25" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ - "heck", - "proc-macro-error", + "heck 0.5.0", "proc-macro2", "quote", - "syn 1.0.107", + "syn 2.0.48", ] [[package]] name = "clap_lex" -version = "0.2.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5538cd660450ebeb4234cfecf8f2284b844ffc4c50531e66d584ad5b91293613" -dependencies = [ - "os_str_bytes", -] +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "combine" @@ -949,7 +1004,7 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81c5131a2895ef64741dad1d483f358c2a229a3a2d1b256778cdc5e146db64d4" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 2.0.48", @@ -1580,7 +1635,7 @@ name = "graph-chain-common" version = "0.34.0" dependencies = [ "anyhow", - "heck", + "heck 0.4.1", "protobuf 3.3.0", "protobuf-parse", ] @@ -1752,7 +1807,7 @@ dependencies = [ name = "graph-runtime-derive" version = "0.34.0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 1.0.107", @@ -1866,6 +1921,7 @@ dependencies = [ "fallible-iterator 0.3.0", "git-testament", "graph", + "graphql-parser", "hex", "itertools 0.12.0", "lazy_static", @@ -2031,6 +2087,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -3116,12 +3178,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "os_str_bytes" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" - [[package]] name = "pad" version = "0.1.6" @@ -3480,7 +3536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb5320c680de74ba083512704acb90fe00f28f79207286a848e730c45dd73ed6" dependencies = [ "bytes", - "heck", + "heck 0.4.1", "itertools 0.10.5", "lazy_static", "log", @@ -4306,7 +4362,7 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 1.0.107", @@ -4426,9 +4482,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum_macros" @@ -4436,7 +4492,7 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -4642,12 +4698,6 @@ dependencies = [ "prost-types", ] -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" version = "1.0.57" @@ -5344,6 +5394,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "uuid" version = "1.8.0" @@ -5796,7 +5852,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b804dfd3d0c0d6d37aa21026fe7772ba1a769c89ee4f5c4f13b82d91d75216f" dependencies = [ "anyhow", - "heck", + "heck 0.4.1", "indexmap 2.1.0", "wit-parser", ] diff --git a/Cargo.toml b/Cargo.toml index 19799e19ef0..cc550f2d0a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ tonic = { version = "0.8.3", features = ["tls-roots", "gzip"] } tonic-build = { version = "0.8.4", features = ["prost"] } wasmtime = "15.0.1" wasmparser = "0.118.1" +clap = { version = "4.5.4", features = ["derive", "env"] } # Incremental compilation on Rust 1.58 causes an ICE on build. As soon as graph node builds again, these can be removed. [profile.test] diff --git a/graph/Cargo.toml b/graph/Cargo.toml index 8f98329ea1a..0b1e97b20cf 100644 --- a/graph/Cargo.toml +++ b/graph/Cargo.toml @@ -94,7 +94,7 @@ csv = "1.3.0" object_store = { version = "0.9.1", features = ["gcp"] } [dev-dependencies] -clap = { version = "3.2.25", features = ["derive", "env"] } +clap.workspace = true maplit = "1.0.2" hex-literal = "0.4" diff --git a/graph/examples/stress.rs b/graph/examples/stress.rs index 5fbfb2f82ad..7e96d914fea 100644 --- a/graph/examples/stress.rs +++ b/graph/examples/stress.rs @@ -675,7 +675,7 @@ fn stress(opt: &Opt) { /// memory used on the heap since we started inserting into the cache to /// the target `cache_size` pub fn main() { - let opt = Opt::from_args(); + let opt = Opt::parse(); unsafe { PRINT_SAMPLES = opt.samples } // Use different Cacheables to see how the cache manages memory with diff --git a/node/Cargo.toml b/node/Cargo.toml index 0884d5d74cd..3ed9c090d75 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -13,7 +13,7 @@ name = "graphman" path = "src/bin/manager.rs" [dependencies] -clap = { version = "3.2.25", features = ["derive", "env"] } +clap.workspace = true env_logger = "0.10.1" git-testament = "0.2" futures = { version = "0.3.1", features = ["compat"] } diff --git a/node/src/bin/manager.rs b/node/src/bin/manager.rs index 838fcdbbeab..f91e2b85213 100644 --- a/node/src/bin/manager.rs +++ b/node/src/bin/manager.rs @@ -187,7 +187,7 @@ pub enum Command { long, short, default_value = "20", - parse(try_from_str = parse_duration_in_secs) + value_parser = parse_duration_in_secs )] sleep: Duration, }, @@ -205,7 +205,7 @@ pub enum Command { long, short, default_value = "20", - parse(try_from_str = parse_duration_in_secs) + value_parser = parse_duration_in_secs )] sleep: Duration, /// The block hash of the target block @@ -225,7 +225,7 @@ pub enum Command { )] block_number: Option, /// The deployments to rewind (see `help info`) - #[clap(required = true, min_values = 1)] + #[clap(required = true)] deployments: Vec, }, /// Deploy and run an arbitrary subgraph up to a certain block @@ -534,13 +534,13 @@ pub enum ChainCommand { #[clap(subcommand)] // Note that we mark a field as a subcommand method: CheckBlockMethod, /// Chain name (must be an existing chain, see 'chain list') - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] chain_name: String, }, /// Truncates the whole block cache for the given chain. Truncate { /// Chain name (must be an existing chain, see 'chain list') - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] chain_name: String, /// Skips confirmation prompt #[clap(long, short)] @@ -550,10 +550,10 @@ pub enum ChainCommand { /// Change the block cache shard for a chain ChangeShard { /// Chain name (must be an existing chain, see 'chain list') - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] chain_name: String, /// Shard name - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] shard: String, }, @@ -562,7 +562,7 @@ pub enum ChainCommand { #[clap(subcommand)] method: CallCacheCommand, /// Chain name (must be an existing chain, see 'chain list') - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] chain_name: String, }, } @@ -674,24 +674,24 @@ pub enum IndexCommand { /// This command may be time-consuming. Create { /// The deployment (see `help info`). - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] deployment: DeploymentSearch, /// The Entity name. /// /// Can be expressed either in upper camel case (as its GraphQL definition) or in snake case /// (as its SQL table name). - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] entity: String, /// The Field names. /// /// Each field can be expressed either in camel case (as its GraphQL definition) or in snake /// case (as its SQL colmun name). - #[clap(min_values = 1, required = true)] + #[clap(required = true)] fields: Vec, /// The index method. Defaults to `btree`. #[clap( short, long, default_value = "btree", - possible_values = &["btree", "hash", "gist", "spgist", "gin", "brin"] + value_parser = clap::builder::PossibleValuesParser::new(&["btree", "hash", "gist", "spgist", "gin", "brin"]) )] method: String, @@ -718,23 +718,23 @@ pub enum IndexCommand { #[clap(long, requires = "sql")] if_not_exists: bool, /// The deployment (see `help info`). - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] deployment: DeploymentSearch, /// The Entity name. /// /// Can be expressed either in upper camel case (as its GraphQL definition) or in snake case /// (as its SQL table name). - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] entity: String, }, /// Drops an index for a given deployment, concurrently Drop { /// The deployment (see `help info`). - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] deployment: DeploymentSearch, /// The name of the index to be dropped - #[clap(empty_values = false)] + #[clap(value_parser = clap::builder::NonEmptyStringValueParser::new())] index_name: String, }, } diff --git a/node/src/opt.rs b/node/src/opt.rs index 06eb161c431..2071bf4723b 100644 --- a/node/src/opt.rs +++ b/node/src/opt.rs @@ -21,7 +21,7 @@ pub struct Opt { long, env = "GRAPH_NODE_CONFIG", conflicts_with_all = &["postgres-url", "postgres-secondary-hosts", "postgres-host-weights"], - required_unless = "postgres-url", + required_unless_present = "postgres-url", help = "the name of the configuration file", )] pub config: Option, @@ -48,14 +48,14 @@ pub struct Opt { value_name = "URL", env = "POSTGRES_URL", conflicts_with = "config", - required_unless = "config", + required_unless_present = "config", help = "Location of the Postgres database used for storing entities" )] pub postgres_url: Option, #[clap( long, value_name = "URL,", - use_delimiter = true, + use_value_delimiter = true, env = "GRAPH_POSTGRES_SECONDARY_HOSTS", conflicts_with = "config", help = "Comma-separated list of host names/IP's for read-only Postgres replicas, \ @@ -66,7 +66,7 @@ pub struct Opt { #[clap( long, value_name = "WEIGHT,", - use_delimiter = true, + use_value_delimiter = true, env = "GRAPH_POSTGRES_HOST_WEIGHTS", conflicts_with = "config", help = "Comma-separated list of relative weights for selecting the main database \ @@ -77,24 +77,25 @@ pub struct Opt { pub postgres_host_weights: Vec, #[clap( long, - min_values=0, - required_unless_one = &["ethereum-ws", "ethereum-ipc", "config"], + allow_negative_numbers = false, + required_unless_present_any = &["ethereum-ws", "ethereum-ipc", "config"], conflicts_with_all = &["ethereum-ws", "ethereum-ipc", "config"], value_name="NETWORK_NAME:[CAPABILITIES]:URL", env="ETHEREUM_RPC", help= "Ethereum network name (e.g. 'mainnet'), optional comma-seperated capabilities (eg 'full,archive'), and an Ethereum RPC URL, separated by a ':'", )] pub ethereum_rpc: Vec, - #[clap(long, min_values=0, - required_unless_one = &["ethereum-rpc", "ethereum-ipc", "config"], + #[clap(long, allow_negative_numbers = false, + required_unless_present_any = &["ethereum-rpc", "ethereum-ipc", "config"], conflicts_with_all = &["ethereum-rpc", "ethereum-ipc", "config"], value_name="NETWORK_NAME:[CAPABILITIES]:URL", env="ETHEREUM_WS", help= "Ethereum network name (e.g. 'mainnet'), optional comma-seperated capabilities (eg 'full,archive`, and an Ethereum WebSocket URL, separated by a ':'", )] pub ethereum_ws: Vec, - #[clap(long, min_values=0, - required_unless_one = &["ethereum-rpc", "ethereum-ws", "config"], + #[clap(long, + allow_negative_numbers = false, + required_unless_present_any = &["ethereum-rpc", "ethereum-ws", "config"], conflicts_with_all = &["ethereum-rpc", "ethereum-ws", "config"], value_name="NETWORK_NAME:[CAPABILITIES]:FILE", env="ETHEREUM_IPC", diff --git a/runtime/test/src/test.rs b/runtime/test/src/test.rs index 5610e82a7d0..787626db29d 100644 --- a/runtime/test/src/test.rs +++ b/runtime/test/src/test.rs @@ -1485,8 +1485,6 @@ async fn test_store_set_id() { async fn test_store_set_invalid_fields() { const UID: &str = "u1"; const USER: &str = "User"; - // const BID: &str = "0xdeadbeef"; - // const BINARY: &str = "Binary"; let schema = " type User @entity { id: ID!, diff --git a/store/postgres/Cargo.toml b/store/postgres/Cargo.toml index 4a7340f1f79..ab8160c702b 100644 --- a/store/postgres/Cargo.toml +++ b/store/postgres/Cargo.toml @@ -32,4 +32,5 @@ hex = "0.4.3" pretty_assertions = "1.4.0" [dev-dependencies] -clap = "3.2.25" +clap.workspace = true +graphql-parser = "0.4.0"