mecha10-cli 0.8.0

Mecha10 CLI tool
Documentation
//! Auth command handlers
//!
//! Thin wrappers around the shared login/logout/whoami orchestration in `mecha10_auth::commands`.

use crate::commands::auth::{LoginArgs, WhoamiArgs};
use anyhow::Result;

const BINARY_NAME: &str = "mecha10";

/// Handle the login command
///
/// Runs the device code authentication flow, polling until the user completes auth or the
/// code expires, then saves credentials on success.
pub async fn handle_login(args: &LoginArgs) -> Result<()> {
    mecha10_auth::commands::handle_login(args.auth_url.clone(), BINARY_NAME).await
}

/// Handle the logout command
///
/// Removes stored credentials from ~/.mecha10/credentials.json
pub async fn handle_logout() -> Result<()> {
    mecha10_auth::commands::handle_logout()
}

/// Handle the whoami command
///
/// Displays current authentication status and user info
pub async fn handle_whoami(args: &WhoamiArgs) -> Result<()> {
    mecha10_auth::commands::handle_whoami(args.verbose, BINARY_NAME)
}