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!("{}...{}", &token[..6.min(token.len())], &token[token.len().saturating_sub(4)..]);
23                println!("Token:     {}", masked);
24            }
25            match &config.defaults.workspace_id {
26                Some(ws) => println!("Workspace: {}", ws),
27                None => println!("Workspace: (not set)"),
28            }
29        }
30        Err(_) => {
31            println!("Token:     (not configured)");
32            println!("Workspace: (not configured)");
33            println!();
34            println!("Run 'clickup setup' to configure.");
35            return Ok(());
36        }
37    }
38
39    // Env overrides
40    if std::env::var("CLICKUP_TOKEN").is_ok() {
41        println!("           (CLICKUP_TOKEN env var set — overrides config)");
42    }
43    if std::env::var("CLICKUP_WORKSPACE").is_ok() {
44        println!("           (CLICKUP_WORKSPACE env var set — overrides config)");
45    }
46    if cli.token.is_some() {
47        println!("           (--token flag set — overrides all)");
48    }
49
50    Ok(())
51}