Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade clap #5174

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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]
Expand Down
2 changes: 1 addition & 1 deletion graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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"

Expand Down
2 changes: 1 addition & 1 deletion graph/examples/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ fn stress<T: Template>(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
Expand Down
6 changes: 5 additions & 1 deletion graph/examples/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct Entry {
schema: String,
}

#[derive(Clone)]
enum RunMode {
Validate,
Size,
Expand Down Expand Up @@ -145,7 +146,10 @@ struct Opts {
batch: bool,
#[clap(long)]
api: bool,
#[clap(short, long, default_value = "validate", possible_values = &["validate", "size"])]
#[clap(
short, long, default_value = "validate",
value_parser = clap::builder::PossibleValuesParser::new(&["validate", "size"])
)]
mode: RunMode,
/// Subgraph schemas to validate
#[clap(required = true)]
Expand Down
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ name = "graphman"
path = "src/bin/manager.rs"

[dependencies]
clap = { version = "3.2.25", features = ["derive", "env"] }
env_logger = "0.11.3"
clap.workspace = true
git-testament = "0.2"
lazy_static = "1.2.0"
url = "2.5.0"
Expand Down
34 changes: 17 additions & 17 deletions node/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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
Expand All @@ -225,7 +225,7 @@ pub enum Command {
)]
block_number: Option<i32>,
/// The deployments to rewind (see `help info`)
#[clap(required = true, min_values = 1)]
#[clap(required = true)]
deployments: Vec<DeploymentSearch>,
},
/// Deploy and run an arbitrary subgraph up to a certain block
Expand Down Expand Up @@ -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)]
Expand All @@ -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,
},

Expand All @@ -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,
},
}
Expand Down Expand Up @@ -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<String>,
/// The index method. Defaults to `btree` in general, and to `gist` when the index includes the `block_range` column
#[clap(
short, long,
possible_values = &["btree", "hash", "gist", "spgist", "gin", "brin"]
short, long, default_value = "btree",
value_parser = clap::builder::PossibleValuesParser::new(&["btree", "hash", "gist", "spgist", "gin", "brin"])
)]
method: Option<String>,

Expand All @@ -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,
},
}
Expand Down
29 changes: 15 additions & 14 deletions node/src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub struct Opt {
#[clap(
long,
env = "GRAPH_NODE_CONFIG",
conflicts_with_all = &["postgres-url", "postgres-secondary-hosts", "postgres-host-weights"],
required_unless = "postgres-url",
conflicts_with_all = &["postgres_url", "postgres_secondary_hosts", "postgres_host_weights"],
required_unless_present = "postgres_url",
help = "the name of the configuration file",
)]
pub config: Option<String>,
Expand All @@ -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<String>,
#[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, \
Expand All @@ -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 \
Expand All @@ -77,25 +77,26 @@ pub struct Opt {
pub postgres_host_weights: Vec<usize>,
#[clap(
long,
min_values=0,
required_unless_one = &["ethereum-ws", "ethereum-ipc", "config"],
conflicts_with_all = &["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<String>,
#[clap(long, min_values=0,
required_unless_one = &["ethereum-rpc", "ethereum-ipc", "config"],
conflicts_with_all = &["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<String>,
#[clap(long, min_values=0,
required_unless_one = &["ethereum-rpc", "ethereum-ws", "config"],
conflicts_with_all = &["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",
help= "Ethereum network name (e.g. 'mainnet'), optional comma-seperated capabilities (eg 'full,archive'), and an Ethereum IPC pipe, separated by a ':'",
Expand Down
2 changes: 0 additions & 2 deletions runtime/test/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!,
Expand Down
3 changes: 2 additions & 1 deletion store/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading