From cc9e711167e1238f653f6820244e1b2cab1dcc49 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 17 Jan 2022 14:28:25 +1100 Subject: [PATCH] Upgrade `database` to clap 3. Pretty minor stuff, mostly renamed functions. --- Cargo.lock | 61 +++----------------------- database/Cargo.toml | 2 +- database/src/bin/postgres-to-sqlite.rs | 16 +++---- database/src/bin/sqlite-to-postgres.rs | 5 ++- 4 files changed, 17 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 381b93045..a43c24426 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,15 +61,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -211,21 +202,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "clap" -version = "2.33.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" -dependencies = [ - "ansi_term 0.11.0", - "atty", - "bitflags", - "strsim 0.8.0", - "textwrap 0.11.0", - "unicode-width", - "vec_map", -] - [[package]] name = "clap" version = "3.0.6" @@ -238,9 +214,9 @@ dependencies = [ "indexmap", "lazy_static", "os_str_bytes", - "strsim 0.10.0", + "strsim", "termcolor", - "textwrap 0.14.2", + "textwrap", ] [[package]] @@ -262,7 +238,7 @@ version = "0.1.0" dependencies = [ "anyhow", "chrono", - "clap 3.0.6", + "clap", "crossbeam-utils", "database", "env_logger", @@ -374,7 +350,7 @@ dependencies = [ "async-trait", "bytes", "chrono", - "clap 2.33.3", + "clap", "csv", "env_logger", "futures", @@ -1367,7 +1343,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cab0e7c02cf376875e9335e0ba1da535775beb5450d21e1dffca068818ed98b" dependencies = [ - "ansi_term 0.12.1", + "ansi_term", "ctor", "diff", "output_vt100", @@ -1881,12 +1857,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.10.0" @@ -1944,15 +1914,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "textwrap" version = "0.14.2" @@ -2143,12 +2104,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-width" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" - [[package]] name = "unicode-xid" version = "0.2.2" @@ -2179,12 +2134,6 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "025ce40a007e1907e58d5bc1a594def78e5573bb0b1160bc389634e8f12e4faa" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.3" diff --git a/database/Cargo.toml b/database/Cargo.toml index a8d836e0d..87cdb635f 100644 --- a/database/Cargo.toml +++ b/database/Cargo.toml @@ -25,4 +25,4 @@ futures = "0.3.5" log = "0.4" bytes = "1" csv = "1" -clap = "2.25" +clap = { version = "3.0.6", features = ["cargo"] } diff --git a/database/src/bin/postgres-to-sqlite.rs b/database/src/bin/postgres-to-sqlite.rs index 6181c1b5a..a7c9ebc2a 100644 --- a/database/src/bin/postgres-to-sqlite.rs +++ b/database/src/bin/postgres-to-sqlite.rs @@ -4,7 +4,6 @@ //! transactions, and will likely fail if used on a populated database. use chrono::{DateTime, Utc}; -use clap::value_t; use database::pool::{postgres, sqlite, ConnectionManager}; use futures::StreamExt; use rusqlite::params; @@ -464,8 +463,9 @@ async fn main() -> anyhow::Result<()> { let matches = clap::App::new("postgres-to-sqlite") .about("Exports a rustc-perf Postgres database to a SQLite database") + .version(clap::crate_version!()) .arg( - clap::Arg::with_name("exclude-tables") + clap::Arg::new("exclude-tables") .long("exclude-tables") .takes_value(true) .value_name("TABLES") @@ -474,24 +474,24 @@ async fn main() -> anyhow::Result<()> { .help("Exclude given tables (as foreign key constraints allow)"), ) .arg( - clap::Arg::with_name("no-self-profile") + clap::Arg::new("no-self-profile") .long("no-self-profile") .help("Exclude some potentially large self-profile tables (additive with --exclude-tables)"), ) .arg( - clap::Arg::with_name("since-weeks-ago") + clap::Arg::new("since-weeks-ago") .long("since-weeks-ago") .takes_value(true) .value_name("WEEKS") .help("Exclude data associated with artifacts whose date value precedes weeks ago"), ) .arg( - clap::Arg::with_name("fast-unsafe") + clap::Arg::new("fast-unsafe") .long("fast-unsafe") .help("Enable faster execution at the risk of corrupting SQLite database in the event of a crash"), ) .arg( - clap::Arg::with_name("postgres-db") + clap::Arg::new("postgres-db") .required(true) .value_name("POSTGRES_DB") .help( @@ -500,7 +500,7 @@ async fn main() -> anyhow::Result<()> { ), ) .arg( - clap::Arg::with_name("sqlite-db") + clap::Arg::new("sqlite-db") .required(true) .value_name("SQLITE_DB") .help("SQLite database file"), @@ -521,7 +521,7 @@ async fn main() -> anyhow::Result<()> { // `RawSelfProfile` is intentionally kept. } - let since_weeks_ago = match clap::value_t!(matches, "since-weeks-ago", u32) { + let since_weeks_ago = match matches.value_of_t("since-weeks-ago") { Ok(weeks) => Some(weeks), Err(err) if err.kind == clap::ErrorKind::ArgumentNotFound => None, Err(err) => err.exit(), diff --git a/database/src/bin/sqlite-to-postgres.rs b/database/src/bin/sqlite-to-postgres.rs index aed8a7513..abfc3a50d 100644 --- a/database/src/bin/sqlite-to-postgres.rs +++ b/database/src/bin/sqlite-to-postgres.rs @@ -614,14 +614,15 @@ async fn main() -> anyhow::Result<()> { let matches = clap::App::new("sqlite-to-postgres") .about("Exports a rustc-perf SQLite database to a Postgres database") + .version(clap::crate_version!()) .arg( - clap::Arg::with_name("sqlite-db") + clap::Arg::new("sqlite-db") .required(true) .value_name("SQLITE_DB") .help("SQLite database file"), ) .arg( - clap::Arg::with_name("postgres-db") + clap::Arg::new("postgres-db") .required(true) .value_name("POSTGRES_DB") .help(