Skip to content

Commit

Permalink
Upgrade database to clap 3.
Browse files Browse the repository at this point in the history
Pretty minor stuff, mostly renamed functions.
  • Loading branch information
nnethercote committed Jan 17, 2022
1 parent 60df383 commit cc9e711
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 67 deletions.
61 changes: 5 additions & 56 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion database/Cargo.toml
Expand Up @@ -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"] }
16 changes: 8 additions & 8 deletions database/src/bin/postgres-to-sqlite.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand All @@ -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> 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(
Expand All @@ -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"),
Expand All @@ -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(),
Expand Down
5 changes: 3 additions & 2 deletions database/src/bin/sqlite-to-postgres.rs
Expand Up @@ -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(
Expand Down

0 comments on commit cc9e711

Please sign in to comment.