//! `ph status`: Show configuration and authentication status.

use ph_cli_core::{Client, Result};

/// Execute the status command.
pub async fn execute(client: &Client) -> Result<()> {
    let config = client.config();

    println!("\n  === ph-cli Status ===\n");

    // Auth status
    if client.is_authenticated() {
        println!("  Auth:             Authenticated");
        if config.has_developer_token() {
            println!("  Method:           Developer Token");
        } else {
            println!("  Method:           OAuth Token");
        }
    } else {
        println!("  Auth:             Not authenticated (run `ph login`)");
    }

    // Config
    println!(
        "\n  Config:           {}",
        ph_cli_core::config::Config::config_path().display()
    );
    println!("  API URL:          {}", config.graphql_url());
    println!("  Timeout:          {}s", config.api.timeout_secs);
    println!("  Retries:          {}", config.api.retry_attempts);
    println!("  Theme:            {}", config.display.theme);
    println!("  Default Limit:    {}", config.display.limit);

    // Auth method status
    if config.has_developer_token() {
        println!("\n  Developer Token:  Configured");
    } else {
        println!("\n  Developer Token:  Not set (run `ph login`)");
    }

    if config.auth.client_id.is_some() {
        println!("  OAuth Client ID:  Configured");
    } else {
        println!("  OAuth Client ID:  Not set");
    }

    println!();
    Ok(())
}
