Skip to content

Commit

Permalink
update clap and fix 1.69 clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
guswynn committed May 2, 2023
1 parent d1fa90a commit 3c4185d
Show file tree
Hide file tree
Showing 26 changed files with 331 additions and 216 deletions.
214 changes: 144 additions & 70 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ skip = [
# up.
{ name = "socket2", version = "0.4.9" },
{ name = "windows-sys", version = "0.42.0" },
{ name = "windows-sys", version = "0.45.0" },
{ name = "windows-targets", version = "0.42.0" },
{ name = "windows_aarch64_gnullvm", version = "0.42.0" },
{ name = "windows_aarch64_msvc", version = "0.42.0" },
{ name = "windows_i686_gnu", version = "0.42.0" },
{ name = "windows_i686_msvc", version = "0.42.0" },
{ name = "windows_x86_64_gnullvm", version = "0.42.0" },
{ name = "windows_x86_64_gnu", version = "0.42.0" },
{ name = "windows_x86_64_msvc", version = "0.42.0" },
# Newer versions of crates like `tempfile` are held back by crates like `atty`.
# This is very Unfortunate as we don't actually use these platforms.
{ name = "hermit-abi", version = "0.1.6" },
{ name = "hermit-abi", version = "0.2.6" },
{ name = "redox_syscall", version = "0.2.10" },

# Waiting for <https://github.com/blackbeam/rust_mysql_common/commit/2a6419aef2ff609cd35a5ce41a9eb48253a8214d>
# to be released.
Expand Down
2 changes: 1 addition & 1 deletion src/cluster/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false
anyhow = "1.0.66"
async-trait = "0.1.59"
bytesize = "1.1.0"
clap = { version = "3.2.20", features = ["derive", "env"] }
clap = { version = "3.2.24", features = ["derive", "env"] }
crossbeam-channel = "0.5.8"
dec = { version = "0.4.8", features = ["serde"] }
differential-dataflow = { git = "https://github.com/TimelyDataflow/differential-dataflow.git" }
Expand Down
2 changes: 1 addition & 1 deletion src/clusterd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false
[dependencies]
anyhow = "1.0.66"
axum = "0.6.7"
clap = { version = "3.2.20", features = ["derive", "env"] }
clap = { version = "3.2.24", features = ["derive", "env"] }
fail = { version = "0.5.1", features = ["failpoints"] }
futures = "0.3.25"
mz-alloc = { path = "../alloc" }
Expand Down
2 changes: 1 addition & 1 deletion src/compute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false
anyhow = "1.0.66"
async-trait = "0.1.59"
bytesize = "1.1.0"
clap = { version = "3.2.20", features = ["derive", "env"] }
clap = { version = "3.2.24", features = ["derive", "env"] }
crossbeam-channel = "0.5.8"
dec = { version = "0.4.8", features = ["serde"] }
differential-dataflow = { git = "https://github.com/TimelyDataflow/differential-dataflow.git" }
Expand Down
2 changes: 1 addition & 1 deletion src/environmentd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ base64 = "0.13.1"
bytes = "1.3.0"
bytesize = "1.1.0"
chrono = { version = "0.4.23", default-features = false, features = ["std"] }
clap = { version = "3.2.20", features = ["wrap_help", "env", "derive"] }
clap = { version = "3.2.24", features = ["wrap_help", "env", "derive"] }
fail = { version = "0.5.1", features = ["failpoints"] }
futures = "0.3.25"
headers = "0.3.8"
Expand Down
1 change: 1 addition & 0 deletions src/expr/src/scalar/func/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ macro_rules! sqlfunc {
}
}

#[allow(clippy::extra_unused_lifetimes)]
pub fn $fn_name<$lt>($param_name: $input_ty) -> $output_ty {
$body
}
Expand Down
2 changes: 1 addition & 1 deletion src/http-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ http = "0.2.8"
hyper = { version = "0.14.23", features = ["http1", "server"] }
include_dir = "0.7.3"
mz-ore = { path = "../ore", default-features = false, features = ["metrics", "tracing_"] }
prometheus = { version = "0.13.3", default-features = false, features = ["process"] }
prometheus = { version = "0.13.3", default-features = false }
serde = "1.0.152"
serde_json = { version = "1.0.89" }
tokio = { version = "1.24.2", features = ["macros", "rt-multi-thread"] }
Expand Down
2 changes: 1 addition & 1 deletion src/interchange/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ harness = false
anyhow = "1.0.66"
byteorder = "1.4.3"
chrono = { version = "0.4.23", default-features = false, features = ["std"] }
clap = { version = "3.2.20", features = ["derive"] }
clap = { version = "3.2.24", features = ["derive"] }
differential-dataflow = { git = "https://github.com/TimelyDataflow/differential-dataflow.git" }
itertools = "0.10.5"
once_cell = "1.16.0"
Expand Down
2 changes: 1 addition & 1 deletion src/kafka-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false
[dependencies]
anyhow = "1.0.66"
chrono = { version = "0.4.23", default-features = false, features = ["std"] }
clap = { version = "3.2.20", features = ["derive"] }
clap = { version = "3.2.24", features = ["derive"] }
crossbeam = "0.8.2"
mz-avro = { path = "../avro" }
mz-ccsr = { path = "../ccsr" }
Expand Down
2 changes: 1 addition & 1 deletion src/mz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rust-version.workspace = true
[dependencies]
anyhow = "1.0.66"
axum = { version = "0.6.7" }
clap = { version = "3.2.20", features = [ "derive" ] }
clap = { version = "3.2.24", features = [ "derive" ] }
dirs = "4.0.0"
indicatif = "0.17.2"
mz-build-info = { path = "../build-info" }
Expand Down
184 changes: 99 additions & 85 deletions src/mz/src/bin/mz/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ use crate::password::list_passwords;
use crate::region::{print_environment_status, print_region_enabled};
use crate::shell::{check_environment_health, shell};
use crate::utils::run_loading_spinner;
use clap_clippy_hack::*;

mod login;
mod password;
Expand All @@ -112,101 +113,114 @@ pub const BUILD_INFO: BuildInfo = build_info!();

static VERSION: Lazy<String> = Lazy::new(|| BUILD_INFO.semver_version().to_string());

/// Command-line interface for Materialize.
#[derive(Debug, clap::Parser)]
#[clap(
// Do not add anything but structs/enums with Clap derives in this module!
//
// Clap v3 sometimes triggers this warning with subcommands,
// and its unclear if it will be fixed in v3, and not just
// in v4. This can't be overridden at the macro level, and instead must be overridden
// at the module level.
//
// TODO(guswynn): remove this when we are using Clap v4.
#[allow(clippy::almost_swapped)]
mod clap_clippy_hack {
use super::*;

/// Command-line interface for Materialize.
#[derive(Debug, clap::Parser)]
#[clap(
long_about = None,
version = VERSION.as_str(),
)]
struct Args {
/// The configuration profile to use.
#[clap(long, validator = ascii_validator)]
profile: Option<String>,
#[clap(subcommand)]
command: Commands,
}

#[derive(Debug, clap::Subcommand)]
enum Commands {
/// Show commands to interact with passwords
AppPassword(AppPasswordCommand),
/// Open the docs
Docs,
/// Login to a profile and make it the active profile
Login {
/// Login by typing your email and password
#[clap(short, long)]
interactive: bool,

/// Force reauthentication for the profile
#[clap(short, long)]
force: bool,

#[clap(flatten)]
vault: Vault,

/// Override the default API endpoint.
#[clap(long, hide = true, default_value_t)]
endpoint: Endpoint,
},
/// Show commands to interact with regions
Region {
pub struct Args {
/// The configuration profile to use.
#[clap(long, validator = ascii_validator)]
pub profile: Option<String>,
#[clap(subcommand)]
command: RegionCommand,
},
pub command: Commands,
}

/// Show commands to interact with secrets
Secret {
cloud_provider_region: Option<CloudProviderRegion>,
#[derive(Debug, clap::Subcommand)]
pub enum Commands {
/// Show commands to interact with passwords
AppPassword(AppPasswordCommand),
/// Open the docs
Docs,
/// Login to a profile and make it the active profile
Login {
/// Login by typing your email and password
#[clap(short, long)]
interactive: bool,

/// Force reauthentication for the profile
#[clap(short, long)]
force: bool,

#[clap(flatten)]
vault: Vault,

/// Override the default API endpoint.
#[clap(long, hide = true, default_value_t)]
endpoint: Endpoint,
},
/// Show commands to interact with regions
Region {
#[clap(subcommand)]
command: RegionCommand,
},

#[clap(subcommand)]
command: SecretCommand,
},
/// Show commands to interact with secrets
Secret {
cloud_provider_region: Option<CloudProviderRegion>,

/// Connect to a region using a SQL shell
Shell {
cloud_provider_region: Option<CloudProviderRegion>,
},
}
#[clap(subcommand)]
command: SecretCommand,
},

#[derive(Debug, clap::Args)]
struct AppPasswordCommand {
#[clap(subcommand)]
command: AppPasswordSubcommand,
}
/// Connect to a region using a SQL shell
Shell {
cloud_provider_region: Option<CloudProviderRegion>,
},
}

#[derive(Debug, clap::Subcommand)]
enum AppPasswordSubcommand {
/// Create a password.
Create {
/// Name for the password.
name: String,
},
/// List all enabled passwords.
List,
}
#[derive(Debug, clap::Args)]
pub struct AppPasswordCommand {
#[clap(subcommand)]
pub command: AppPasswordSubcommand,
}

#[derive(Debug, clap::Subcommand)]
enum RegionCommand {
/// Enable a region.
Enable {
cloud_provider_region: CloudProviderRegion,
#[clap(long, hide = true)]
version: Option<String>,
#[clap(long, hide = true)]
environmentd_extra_arg: Vec<String>,
},
/// Disable a region.
#[clap(hide = true)]
Disable {
cloud_provider_region: CloudProviderRegion,
},
/// List all enabled regions.
List,
/// Display a region's status.
Status {
cloud_provider_region: CloudProviderRegion,
},
#[derive(Debug, clap::Subcommand)]
pub enum AppPasswordSubcommand {
/// Create a password.
Create {
/// Name for the password.
name: String,
},
/// List all enabled passwords.
List,
}

#[derive(Debug, clap::Subcommand)]
pub enum RegionCommand {
/// Enable a region.
Enable {
cloud_provider_region: CloudProviderRegion,
#[clap(long, hide = true)]
version: Option<String>,
#[clap(long, hide = true)]
environmentd_extra_arg: Vec<String>,
},
/// Disable a region.
#[clap(hide = true)]
Disable {
cloud_provider_region: CloudProviderRegion,
},
/// List all enabled regions.
List,
/// Display a region's status.
Status {
cloud_provider_region: CloudProviderRegion,
},
}
}

/// Internal types, struct and enums
Expand Down
68 changes: 41 additions & 27 deletions src/mz/src/bin/mz/secrets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,48 @@ use serde::{Deserialize, Serialize};
use mz::api::{get_provider_region_environment, CloudProviderRegion};
use mz::configuration::ValidProfile;

#[derive(Debug, Subcommand)]
pub enum SecretCommand {
/// Create a new secret
Create {
/// The name of the secret to create
name: String,

#[clap(flatten)]
contents: Contents,
},

/// Delete a secret
Delete {
/// The name of the secret to create
name: String,
},

// List all secrets
List,

/// Update a secret
Update {
/// The name of the secret to update
name: String,
pub use clap_clippy_hack::*;

#[clap(flatten)]
contents: Contents,
},
// Do not add anything but structs/enums with Clap derives in this module!
//
// Clap v3 sometimes triggers this warning with subcommands,
// and its unclear if it will be fixed in v3, and not just
// in v4. This can't be overridden at the macro level, and instead must be overridden
// at the module level.
//
// TODO(guswynn): remove this when we are using Clap v4.
#[allow(clippy::almost_swapped)]
mod clap_clippy_hack {
use super::*;
#[derive(Debug, Subcommand)]
pub enum SecretCommand {
/// Create a new secret
Create {
/// The name of the secret to create
name: String,

#[clap(flatten)]
contents: Contents,
},

/// Delete a secret
Delete {
/// The name of the secret to create
name: String,
},

// List all secrets
List,

/// Update a secret
Update {
/// The name of the secret to update
name: String,

#[clap(flatten)]
contents: Contents,
},
}
}

impl SecretCommand {
Expand Down
2 changes: 1 addition & 1 deletion src/orchestrator-kubernetes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false
anyhow = "1.0.66"
async-trait = "0.1.59"
chrono = { version = "0.4.23", default-features = false }
clap = { version = "3.2.20", features = ["derive"] }
clap = { version = "3.2.24", features = ["derive"] }
fail = { version = "0.5.1", features = ["failpoints"] }
futures = "0.3.25"
maplit = "1.0.2"
Expand Down
Loading

0 comments on commit 3c4185d

Please sign in to comment.