Skip to content

Commit 3d19e4f

Browse files
committed
Use clap in sqlite-to-postgres
1 parent 16e018d commit 3d19e4f

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

database/src/bin/sqlite-to-postgres.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -612,20 +612,27 @@ impl<'a> TryFrom<rusqlite::types::ValueRef<'a>> for Nullable<&'a str> {
612612
async fn main() -> anyhow::Result<()> {
613613
env_logger::init();
614614

615-
let mut args = std::env::args();
616-
let executable = args.next().unwrap();
617-
618-
if args.len() != 2 {
619-
eprintln!(
620-
"Usage: {0} <sqlite-db> <postgres-db>\n\
621-
E.g.: {0} results.db postgres://user:password@localhost:5432",
622-
executable,
623-
);
624-
std::process::exit(1);
625-
}
626-
627-
let sqlite = args.next().unwrap();
628-
let postgres = args.next().unwrap();
615+
let matches = clap::App::new("sqlite-to-postgres")
616+
.about("Exports a rustc-perf SQLite database to a Postgres database")
617+
.arg(
618+
clap::Arg::with_name("sqlite-db")
619+
.required(true)
620+
.value_name("SQLITE_DB")
621+
.help("SQLite database file"),
622+
)
623+
.arg(
624+
clap::Arg::with_name("postgres-db")
625+
.required(true)
626+
.value_name("POSTGRES_DB")
627+
.help(
628+
"Postgres database connection string, \
629+
e.g. postgres://user:password@localhost:5432",
630+
),
631+
)
632+
.get_matches();
633+
634+
let postgres = matches.value_of("postgres-db").unwrap();
635+
let sqlite = matches.value_of("sqlite-db").unwrap();
629636

630637
let mut sqlite = sqlite::Sqlite::new(sqlite.into())
631638
.open()

0 commit comments

Comments
 (0)