pandora_kit/lib.rs
1//! **CLI toolkit with interactive TUI popups for shell scripts and terminal workflows.**
2//!
3//! The main binary is `pan`. Each subcommand opens an interactive terminal popup:
4//!
5//! | Command | Description | Output |
6//! |-----------|--------------------------------|----------------------------|
7//! | `confirm` | Popup de confirmación sí/no | exit 0 / 1 |
8//! | `choose` | Selector de una lista de ítems | ítems en stdout |
9//! | `filter` | Selector con búsqueda por texto| ítems en stdout |
10//! | `spin` | Spinner animado | exit del comando |
11//! | `input` | Captura de texto libre | texto en stdout |
12//! | `file` | Explorador interactivo de archivos | paths en stdout |
13//! | `menu` | Menú jerárquico | path en stdout |
14//! | `log` | Línea de log formateada | texto a stdout |
15//! | `update` | Auto-actualización | mensajes en stdout |
16//!
17//! ## Guías detalladas
18//!
19//! Cada subcomando tiene su guía detallada en `pandora/guides/`.
20//! Ejecutá `pan <subcomando> --guide` para verla en el terminal.
21
22mod choose;
23mod confirm;
24pub mod drag;
25mod file;
26mod filter;
27mod input;
28mod keybinds;
29mod log;
30mod menu;
31pub mod popup_config;
32pub mod popup_rect;
33mod spin;
34mod style;
35mod tty;
36mod update;
37
38use clap::{Parser, Subcommand};
39
40const PANDORA_GUIDE: &str = include_str!("../guides/PANDORA_GUIDE.md");
41pub const BIN_NAME: &str = "pan";
42
43#[derive(Parser)]
44#[command(name = BIN_NAME, about = "CLI toolkit with interactive TUI popups", version = env!("CARGO_PKG_VERSION"))]
45struct Cli {
46 /// Display the complete pan guide
47 #[arg(long)]
48 guide: bool,
49
50 #[command(subcommand)]
51 command: Option<Commands>,
52}
53
54#[derive(Subcommand)]
55enum Commands {
56 /// Show a confirmation popup, returns 0 on accept, 1 on cancel
57 Confirm(confirm::ConfirmArgs),
58 /// Show an interactive item selector
59 Choose(choose::ChooseArgs),
60 /// Show an interactive filter & select popup
61 Filter(filter::FilterArgs),
62 /// Show an animated spinner popup
63 Spin(spin::SpinArgs),
64 /// Print a formatted log line
65 Log(log::LogArgs),
66 /// Open an interactive file browser
67 File(file::FileArgs),
68 /// Capture text input from the user
69 Input(input::InputArgs),
70 /// Interactive tree menu from JSON or plano input
71 Menu(menu::MenuArgs),
72 /// Self-update to the latest release
73 Update(update::UpdateArgs),
74}
75
76pub fn entrypoint() {
77 let cli = Cli::parse();
78
79 if cli.guide {
80 println!("{}", PANDORA_GUIDE);
81 return;
82 }
83
84 match cli.command {
85 Some(Commands::Confirm(args)) => confirm::run(args),
86 Some(Commands::Choose(args)) => choose::run(args),
87 Some(Commands::Filter(args)) => filter::run(args),
88 Some(Commands::Spin(args)) => spin::run(args),
89 Some(Commands::Log(args)) => log::run(args),
90 Some(Commands::File(args)) => file::run(args),
91 Some(Commands::Input(args)) => input::run(args),
92 Some(Commands::Menu(args)) => menu::run(args),
93 Some(Commands::Update(args)) => update::run(args),
94 None => {
95 let mut cmd = <Cli as clap::CommandFactory>::command();
96 cmd.print_help().unwrap();
97 println!();
98 }
99 }
100}