1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Logout command - remove stored authentication token
use crate::auth::AuthConfig;
use crate::error::Result;
pub fn run(json: bool) -> Result<()> {
// Check if user is logged in
let has_token = AuthConfig::has_token();
if !has_token {
if json {
println!(
"{}",
serde_json::json!({
"success": true,
"message": "Already logged out"
})
);
} else {
println!();
println!(" Already logged out.");
println!();
}
return Ok(());
}
// Delete the auth file
AuthConfig::clear_token()?;
if json {
println!(
"{}",
serde_json::json!({
"success": true,
"message": "Logged out successfully"
})
);
} else {
println!();
println!(" 🗡️ Logged out successfully");
println!();
}
Ok(())
}