Misc #35

Merged
oysteikt merged 13 commits from misc into main 2024-08-07 17:29:15 +02:00
2 changed files with 18 additions and 10 deletions
Showing only changes of commit 3d7d001f65 - Show all commits

View File

@ -62,6 +62,9 @@ pub struct UserPasswdArgs {
pub struct UserShowArgs { pub struct UserShowArgs {
#[arg(num_args = 0..)] #[arg(num_args = 0..)]
username: Vec<String>, username: Vec<String>,
#[clap(short, long)]
json: bool,
} }
pub async fn handle_command(command: UserCommand, mut conn: MySqlConnection) -> anyhow::Result<()> { pub async fn handle_command(command: UserCommand, mut conn: MySqlConnection) -> anyhow::Result<()> {
@ -193,16 +196,20 @@ async fn show_users(args: UserShowArgs, conn: &mut MySqlConnection) -> anyhow::R
result result
}; };
for user in users { if args.json {
println!( println!("{}", serde_json::to_string_pretty(&users)?);
"User '{}': {}", } else {
&user.user, for user in users {
if user.has_password { println!(
"password set." "User '{}': {}",
} else { &user.user,
"no password set." if user.has_password {
} "password set."
); } else {
"no password set."
}
);
}
} }
Ok(()) Ok(())

View File

@ -100,6 +100,7 @@ pub struct DatabaseUser {
#[sqlx(rename = "User")] #[sqlx(rename = "User")]
pub user: String, pub user: String,
#[serde(skip)]
#[sqlx(rename = "Host")] #[sqlx(rename = "Host")]
pub host: String, pub host: String,