use clap::{Parser, Subcommand}; use file_service::{AuthDB, Username}; use std::path::PathBuf; #[derive(Subcommand, Debug)] enum Commands { AddUser { username: String }, DeleteUser { username: String }, ListUsers, } #[derive(Parser, Debug)] struct Args { #[command(subcommand)] command: Commands, } #[tokio::main] pub async fn main() { let args = Args::parse(); let authdb = AuthDB::new(PathBuf::from(&std::env::var("AUTHDB").unwrap())) .await .expect("to be able to open the database"); match args.command { Commands::AddUser { username } => { match authdb.add_user(Username::from(username.clone())).await { Ok(token) => { println!("User {} created. Auth token: {}", username, *token); } Err(err) => { println!("Could not create user {}", username); println!("\tError: {:?}", err); } } } Commands::DeleteUser { .. } => {} Commands::ListUsers => {} } }