Skip to content

Commit

Permalink
upgrade clap
Browse files Browse the repository at this point in the history
  • Loading branch information
mangas committed Apr 11, 2024
1 parent 79e179b commit e274183
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 61 deletions.
108 changes: 79 additions & 29 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 @@ -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.4.18", 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 @@ -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"

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
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
32 changes: 16 additions & 16 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`.
#[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,

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
21 changes: 11 additions & 10 deletions node/src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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,24 +77,25 @@ pub struct Opt {
pub postgres_host_weights: Vec<usize>,
#[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<String>,
#[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<String>,
#[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",
Expand Down
Loading

0 comments on commit e274183

Please sign in to comment.