pandora-kit 0.6.0

Interactive TUI toolkit for the Hefesto framework
Documentation
//! **CLI toolkit with interactive TUI popups for shell scripts and terminal workflows.**
//!
//! The main binary is `pan`. Each subcommand opens an interactive terminal popup:
//!
//! | Command   | Description                    | Output                     |
//! |-----------|--------------------------------|----------------------------|
//! | `confirm` | Popup de confirmación sí/no    | exit 0 / 1                 |
//! | `choose`  | Selector de una lista de ítems | ítems en stdout            |
//! | `filter`  | Selector con búsqueda por texto| ítems en stdout            |
//! | `spin`    | Spinner animado                | exit del comando           |
//! | `input`   | Captura de texto libre         | texto en stdout            |
//! | `file`    | Explorador interactivo de archivos | paths en stdout        |
//! | `menu`    | Menú jerárquico                | path en stdout             |
//! | `log`     | Línea de log formateada        | texto a stdout             |
//! | `update`  | Auto-actualización             | mensajes en stdout         |
//!
//! ## Guías detalladas
//!
//! Cada subcomando tiene su guía detallada en `pandora/guides/`.
//! Ejecutá `pan <subcomando> --guide` para verla en el terminal.

mod choose;
mod confirm;
pub mod drag;
mod file;
mod filter;
mod input;
mod keybinds;
mod log;
mod menu;
pub mod popup_config;
pub mod popup_rect;
mod spin;
mod style;
mod tty;
mod update;

use clap::{Parser, Subcommand};

const PANDORA_GUIDE: &str = include_str!("../guides/PANDORA_GUIDE.md");
pub const BIN_NAME: &str = "pan";

#[derive(Parser)]
#[command(name = BIN_NAME, about = "CLI toolkit with interactive TUI popups", version = env!("CARGO_PKG_VERSION"))]
struct Cli {
    /// Display the complete pan guide
    #[arg(long)]
    guide: bool,

    #[command(subcommand)]
    command: Option<Commands>,
}

#[derive(Subcommand)]
enum Commands {
    /// Show a confirmation popup, returns 0 on accept, 1 on cancel
    Confirm(confirm::ConfirmArgs),
    /// Show an interactive item selector
    Choose(choose::ChooseArgs),
    /// Show an interactive filter & select popup
    Filter(filter::FilterArgs),
    /// Show an animated spinner popup
    Spin(spin::SpinArgs),
    /// Print a formatted log line
    Log(log::LogArgs),
    /// Open an interactive file browser
    File(file::FileArgs),
    /// Capture text input from the user
    Input(input::InputArgs),
    /// Interactive tree menu from JSON or plano input
    Menu(menu::MenuArgs),
    /// Self-update to the latest release
    Update(update::UpdateArgs),
}

pub fn entrypoint() {
    let cli = Cli::parse();

    if cli.guide {
        println!("{}", PANDORA_GUIDE);
        return;
    }

    match cli.command {
        Some(Commands::Confirm(args)) => confirm::run(args),
        Some(Commands::Choose(args)) => choose::run(args),
        Some(Commands::Filter(args)) => filter::run(args),
        Some(Commands::Spin(args)) => spin::run(args),
        Some(Commands::Log(args)) => log::run(args),
        Some(Commands::File(args)) => file::run(args),
        Some(Commands::Input(args)) => input::run(args),
        Some(Commands::Menu(args)) => menu::run(args),
        Some(Commands::Update(args)) => update::run(args),
        None => {
            let mut cmd = <Cli as clap::CommandFactory>::command();
            cmd.print_help().unwrap();
            println!();
        }
    }
}