feat: init_cli_app bash pipeline — scaffold Go CLI app con TUI opcional
Genera apps/{nombre}/ con main.go (subcommand routing via os.Args + switch),
cmd_version.go, cmd_status.go, Makefile (build/run/install/test/vet/clean),
.gitignore, go.mod y app.md. Sin cobra/urfave — consistente con el resto de
apps del registry.
Flag --with-tui anade model.go con un modelo Bubbletea fullscreen (lista
filtrable con bubbles/list, spinner con bubbles/spinner, dark theme con
lipgloss). main.go arranca la TUI con tea.NewProgram(m, WithAltScreen) si no
hay args; sino hace subcommand routing normal.
Verifica con go mod tidy + go vet.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
---
|
||||
name: init_cli_app
|
||||
kind: pipeline
|
||||
lang: bash
|
||||
domain: pipelines
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "init_cli_app(nombre: string, [--with-tui]) -> void"
|
||||
description: "Scaffold de Go CLI app con subcomandos (version/status/help) routed via os.Args. Con --with-tui genera model.go con un modelo Bubbletea fullscreen (lista filtrable + spinner + dark theme) y main.go arranca la TUI en modo fullscreen. Sin dependencias de cobra/urfave — consistente con las apps del registry."
|
||||
tags: [init, scaffold, cli, tui, pipeline, bash, launcher]
|
||||
uses_functions:
|
||||
- assert_command_exists_bash_shell
|
||||
- new_base_model_go_tui
|
||||
- dark_styles_go_tui
|
||||
- run_fullscreen_go_tui
|
||||
- new_spinner_go_tui
|
||||
- new_filtered_list_go_tui
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: []
|
||||
params:
|
||||
- name: nombre
|
||||
desc: "nombre de la CLI app (apps/{nombre}/); se usa como binario y como modulo Go"
|
||||
- name: "--with-tui"
|
||||
desc: "anade model.go con modelo Bubbletea (lista + spinner + dark theme) y arranca TUI fullscreen al invocar sin args"
|
||||
output: "CLI app en apps/{nombre}/ con main.go (subcommand routing), cmd_version.go, cmd_status.go, Makefile con targets build/run/install/test/vet/clean. Con --with-tui anade model.go y el default sin args arranca TUI."
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
example: "fn run init_cli_app my_cli --with-tui"
|
||||
file_path: "bash/functions/pipelines/init_cli_app.sh"
|
||||
---
|
||||
|
||||
## Sinopsis
|
||||
|
||||
```bash
|
||||
fn run init_cli_app <nombre> [--with-tui]
|
||||
```
|
||||
|
||||
## Ejemplo rapido
|
||||
|
||||
```bash
|
||||
# CLI clasica
|
||||
fn run init_cli_app mytool
|
||||
cd apps/mytool
|
||||
make build
|
||||
./mytool version
|
||||
./mytool status
|
||||
|
||||
# CLI + TUI fullscreen
|
||||
fn run init_cli_app deploy_helper --with-tui
|
||||
cd apps/deploy_helper
|
||||
make build
|
||||
./deploy_helper # arranca TUI
|
||||
./deploy_helper version # subcomando
|
||||
```
|
||||
|
||||
## Archivos generados
|
||||
|
||||
| Archivo | Descripcion |
|
||||
|---------|-------------|
|
||||
| `main.go` | Entry con `switch os.Args[1]`; subcomandos: version, status, help |
|
||||
| `cmd_version.go` | Imprime nombre + version |
|
||||
| `cmd_status.go` | Imprime app/version/go/os/arch |
|
||||
| `go.mod` | Modulo Go con replace `fn-registry`; con `--with-tui` agrega bubbletea/bubbles/lipgloss |
|
||||
| `Makefile` | Targets build, run (ARGS=...), install (~/.local/bin/), test, vet, clean |
|
||||
| `.gitignore` | Binario + IDE files |
|
||||
| `app.md` | Tag `cli` (o `cli,tui,bubbletea` con `--with-tui`) |
|
||||
|
||||
Con `--with-tui` anade:
|
||||
- `model.go` — `Model` con spinner (spinner.Dot), lista Bubbletea con 4 items de ejemplo, dark theme (lipgloss con colores 7D56F4 / 06B6D4), keys enter/q/ctrl+c
|
||||
- `main.go` arranca la TUI con `tea.NewProgram(model, tea.WithAltScreen())` si no hay args
|
||||
|
||||
## Flags
|
||||
|
||||
| Flag | Efecto |
|
||||
|------|--------|
|
||||
| `--with-tui` | Anade model.go con Bubbletea y TUI fullscreen como default |
|
||||
|
||||
## Post-setup
|
||||
|
||||
```bash
|
||||
cd apps/{nombre}
|
||||
make build # construye ./{nombre}
|
||||
./{nombre} version
|
||||
./{nombre} status
|
||||
make install # copia a ~/.local/bin/{nombre}
|
||||
make run ARGS="status" # build + run con argumentos
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Pipeline impuro: genera archivos, ejecuta `go mod tidy` y `go vet` al final.
|
||||
|
||||
Los ejemplos del modelo TUI (items "Deploy", "Status", "Logs", "Exit") son
|
||||
placeholders — reemplazar con la logica real de la app. El modelo usa los
|
||||
componentes estandar de bubbles (`list`, `spinner`) y lipgloss para estilos.
|
||||
|
||||
Las funciones del registry `new_base_model_go_tui`, `dark_styles_go_tui`,
|
||||
`run_fullscreen_go_tui`, `new_spinner_go_tui`, `new_filtered_list_go_tui`
|
||||
son referenciadas en el frontmatter como deps conceptuales aunque el
|
||||
scaffold inline el codigo Bubbletea directamente (las funciones del registry
|
||||
son stubs que delegan a devfactory/tui).
|
||||
|
||||
Abort si `apps/{nombre}/` ya existe.
|
||||
|
||||
El tag `launcher` permite que aparezca en el Pipeline Launcher TUI (aunque
|
||||
una CLI con TUI interactiva normalmente no se lanza como subprocess).
|
||||
Reference in New Issue
Block a user