Remove auth CLI argument and use user + pass instead

This commit is contained in:
Tobie Morgan Hitchcock 2022-05-07 15:06:46 +01:00
parent 82140410d6
commit 0ff3d0f7d0

View file

@ -7,17 +7,6 @@ mod version;
use clap::{Arg, Command}; use clap::{Arg, Command};
fn auth_valid(v: &str) -> Result<(), String> {
if v.contains(':') {
return Ok(());
}
Err(String::from(
"\
Provide a valid user:pass value separated by a colon, \
or use the --auth-user and --auth-pass flags\
",
))
}
fn file_valid(v: &str) -> Result<(), String> { fn file_valid(v: &str) -> Result<(), String> {
if !v.is_empty() { if !v.is_empty() {
@ -138,33 +127,24 @@ pub fn init() {
.help("Database path used for storing data"), .help("Database path used for storing data"),
) )
.arg( .arg(
Arg::new("auth") Arg::new("user")
.short('a')
.long("auth")
.forbid_empty_values(true)
.validator(auth_valid)
.default_value("root:root")
.help("Master database authentication details"),
)
.arg(
Arg::new("auth-user")
.short('u') .short('u')
.long("auth-user") .long("user")
.forbid_empty_values(true) .forbid_empty_values(true)
.default_value("root") .default_value("root")
.help("The master username for the database"), .help("The master username for the database"),
) )
.arg( .arg(
Arg::new("auth-pass") Arg::new("pass")
.short('p') .short('p')
.long("auth-pass") .long("pass")
.forbid_empty_values(true) .forbid_empty_values(true)
.default_value("root") .default_value("root")
.help("The master password for the database"), .help("The master password for the database"),
) )
.arg( .arg(
Arg::new("auth-addr") Arg::new("addr")
.long("auth-addr") .long("addr")
.number_of_values(1) .number_of_values(1)
.forbid_empty_values(true) .forbid_empty_values(true)
.multiple_occurrences(true) .multiple_occurrences(true)