Skip to main content

clickup_cli/commands/
status.rs

1use crate::config::Config;
2use crate::error::CliError;
3use crate::Cli;
4
5pub async fn execute(cli: &Cli) -> Result<(), CliError> {
6    println!("clickup-cli v{}", env!("CARGO_PKG_VERSION"));
7    println!();
8
9    // Config
10    match Config::config_path() {
11        Ok(path) => println!("Config:    {}", path.display()),
12        Err(_) => println!("Config:    (unknown path)"),
13    }
14
15    // Auth
16    match Config::load() {
17        Ok(config) => {
18            let token = &config.auth.token;
19            if token.is_empty() {
20                println!("Token:     (not set)");
21            } else {
22                let masked = format!(
23                    "{}...{}",
24                    &token[..6.min(token.len())],
25                    &token[token.len().saturating_sub(4)..]
26                );
27                println!("Token:     {}", masked);
28            }
29            match &config.defaults.workspace_id {
30                Some(ws) => println!("Workspace: {}", ws),
31                None => println!("Workspace: (not set)"),
32            }
33        }
34        Err(_) => {
35            println!("Token:     (not configured)");
36            println!("Workspace: (not configured)");
37            println!();
38            println!("Run 'clickup setup' to configure.");
39            return Ok(());
40        }
41    }
42
43    // Env overrides
44    if std::env::var("CLICKUP_TOKEN").is_ok() {
45        println!("           (CLICKUP_TOKEN env var set — overrides config)");
46    }
47    if std::env::var("CLICKUP_WORKSPACE").is_ok() {
48        println!("           (CLICKUP_WORKSPACE env var set — overrides config)");
49    }
50    if cli.token.is_some() {
51        println!("           (--token flag set — overrides all)");
52    }
53
54    Ok(())
55}