feat(otter): cli command to toggle admin status

This commit is contained in:
Jef Roosens 2025-08-29 14:02:26 +02:00
parent ee9db5ae36
commit b946e1ce98
Signed by: Jef Roosens
GPG key ID: 02D4C0997E74717B
6 changed files with 50 additions and 2 deletions

View file

@ -1,4 +1,4 @@
use clap::{Args, Subcommand};
use clap::{ArgAction, Args, Subcommand};
use super::CliError;
@ -22,6 +22,12 @@ pub enum UserCommand {
Add { username: String, password: String },
/// Generate a signup link ID
GenerateSignupLink,
/// Give or remove admin privileges to a user
SetAdmin {
username: String,
#[clap(action=ArgAction::Set)]
is_admin: bool,
},
}
impl Command {
@ -67,6 +73,11 @@ impl UserCommand {
println!("/signup/{}", link.id);
}
Self::SetAdmin { username, is_admin } => {
let mut user = store.get_user(username)?;
user.admin = *is_admin;
store.update_user(user)?;
}
}
Ok(())