1
use bonsaidb_core::connection::StorageConnection;
2
use clap::Subcommand;
3

            
4
#[derive(Subcommand, Debug)]
5
pub enum Command {
6
    #[clap(subcommand)]
7
    User(UserCommand),
8
}
9

            
10
112
#[derive(Subcommand, Debug)]
11
pub enum UserCommand {
12
    List,
13
    Create { username: String },
14
    Delete { username: String },
15
}
16

            
17
impl Command {
18
    pub async fn execute<SC: StorageConnection>(self, server: SC) -> anyhow::Result<()> {
19
        match self {
20
            Command::User(user) => match user {
21
                UserCommand::Create { username } => {
22
                    server.create_user(&username).await?;
23
                    println!("User {} created", username);
24
                    Ok(())
25
                }
26
                UserCommand::List | UserCommand::Delete { .. } => {
27
                    todo!()
28
                }
29
            },
30
        }
31
    }
32
}