quorum_public/cli/user.rs
1use colored::Colorize;
2use quorum_core::db::DB;
3
4/// Deletes a user by ID from the database.
5///
6/// # Arguments
7/// * `db` - A reference to the database connection.
8/// * `raw` - A string slice containing the user ID to delete.
9///
10/// # Example
11/// ```rust
12/// #[tokio::main]
13/// async fn main() {
14/// let db = DB::new("sqlite:memory:").await.unwrap();
15/// delete(&db, "user_id").await;
16/// }
17/// ```
18pub async fn delete(db: &DB, raw: &str) {
19 let id = raw.trim();
20
21 if id.is_empty() {
22 println!("{}", "Usage: user:delete <id>".red());
23 return;
24 }
25
26 match crate::db::queries::auth::delete_user_by_id(db, id).await {
27 Ok(_) => println!("{}", format!(" User {} deleted.", id).green()),
28 Err(e) => println!("{}", format!(" Failed to delete user: {}", e).red()),
29 }
30}