惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
I
Intezer
F
Fortinet All Blogs
S
SegmentFault 最新的问题
罗磊的独立博客
V
Visual Studio Blog
V
V2EX
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
J
Java Code Geeks
美团技术团队
B
Blog
U
Unit 42
F
Full Disclosure
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Privacy International News Feed
G
Google Developers Blog
雷峰网
雷峰网
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
T
Tor Project blog
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
GbyAI
GbyAI
S
Schneier on Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
LINUX DO - 热门话题
Recorded Future
Recorded Future
D
Docker
博客园 - 聂微东
Project Zero
Project Zero
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
K
Kaspersky official blog
Martin Fowler
Martin Fowler
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
Lohrmann on Cybersecurity
A
Arctic Wolf
T
The Blog of Author Tim Ferriss
Microsoft Security Blog
Microsoft Security Blog
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
V
Vulnerabilities – Threatpost
Simon Willison's Weblog
Simon Willison's Weblog
Cisco Talos Blog
Cisco Talos Blog
T
Threatpost
Hugging Face - Blog
Hugging Face - Blog
博客园_首页

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Fitz CLI builder: como typer, pero en el lenguaje
Martin Palopoli · 2026-06-13 · via DEV Community

Construí herramientas CLI nativas en Fitz con @command, sin librería que instalar. Help auto-generado, flags con type coercion, positional args por convención, binario nativo a la salida. El mismo lenguaje que mueve servicios HTTP construye tus scripts.

¿Por qué un CLI builder en el lenguaje?

La mayoría del trabajo de CLI en Python vive en typer, click o argparse. Todas son librerías decentes; typer en particular es delicioso. La respuesta de Rust es clap. La de Go es cobra o urfave/cli. La de Node es commander.js o yargs. Cada lenguaje tiene una librería CLI. Cada una de ellas es una librería.

Una librería está bien hasta que te acordás que:

  • Las convenciones de la librería se imponen al resto de tu código (decoradores, factory objects, DSLs de builder).
  • El formato del help text es decisión de la librería, no del lenguaje.
  • Distribuir el resultado necesita un packager (pyinstaller, pyox, Docker, etc.) arriba.
  • El comportamiento cross-platform depende de la cobertura de la librería, no del lenguaje.
  • Agregar un --flag es cambiar la signature de una función más una llamada a decorador más quizás un objeto de config.

¿Qué pasaría si el mismo compilador que produce tu server HTTP también produce tus CLI tools, con el mismo type checker, el mismo async/await, el mismo Result<T> para errores, el mismo binario nativo como output?

Ese es el CLI builder de Fitz.

El hello-world completo

// main.fitz
@command("greet", desc="Saludar a una persona")
fn greet(name: Str, loud: Bool = false, count: Int = 1) -> Int {
    let n = count
    while n > 0 {
        if loud {
            print("HOLA, {name}!")
        } else {
            print("hola, {name}")
        }
        n = n - 1
    }
    return 0
}

Corrélo local durante el desarrollo:

$ fitz run main.fitz greet Ada
hola, Ada

$ fitz run main.fitz greet Ada --loud --count 3
HOLA, Ada!
HOLA, Ada!
HOLA, Ada!

Compilá a un binario self-contained:

$ fitz build
$ ls -lh ./greeter
-rwxr-xr-x  1  user  user   5.2M  Jun  5 14:00 ./greeter

$ ./greeter greet Ada --loud
HOLA, Ada!

Binario nativo de 5 MB, estáticamente linkeado excepto libc. Sin pyinstaller. Sin pyz. Sin intérprete Python en la máquina destino.

La convención: sin decoradores @arg/@flag

typer y click te piden que marques cada parámetro con un decorador que diga "esto es positional argument" o "esto es flag". Fitz usa una convención que cubre el mismo terreno sin la verbosidad:

  • Param sin default → positional argument requerido (mybin greet <name>).
  • Param con default → flag (--name <value>, o --loud para flags Bool).
  • Bool = false → flag bool (--loud lo activa, sin valor).
  • Int = N, Float = X, Str = "..." → flag con valor (--count 3).

La signature fn greet(name: Str, loud: Bool = false, count: Int = 1) -> Int le dice al compilador exactamente:

Param Convención CLI
name: Str sin default → positional greet <name>
loud: Bool = false bool con default → flag --loud (presencia = true)
count: Int = 1 int con default → flag con valor --count 3

El trade-off: no podés tener positional optional args. Si querés uno, declaralo Str? (nullable) y hacé match en el body — el shape queda bien, el body maneja el caso missing explícito.

Conviví con este trade-off una semana antes de empezar a escribir CLIs en Fitz en lugar de typer, y no volví. La signature es la definición del CLI.

El help es auto-generado

$ ./mybin --help
USAGE:
    mybin <command> [ARGS] [OPTIONS]

COMMANDS:
    greet    Saludar a una persona

$ ./mybin greet --help
USAGE:
    mybin greet <name> [OPTIONS]

ARGUMENTS:
    <name>     (requerido)

OPTIONS:
    --loud, -l           default: false
    --count, -c <count>  default: 1
    -h, --help           mostrar este help

Short flags (-l, -c) se auto-derivan de la primera letra de la long flag. Si dos flags colisionarían en la misma letra, el compilador te avisa en build time (no en runtime, no cuando el user lo descubre):

✗ @command("greet") short flag conflict: `--loud` y `--limit`
  comparten primera letra `-l`. Renombrá una, u opt-out una con
  `@flag(short=null)`.

El formateo del output sigue convenciones de clap porque clap ya optimizó esto; no tiene sentido reinventarlo.

Multi-command dispatch

@command("greet", desc="Saludar a una persona")
fn greet(name: Str) -> Int { print("hola, {name}"); return 0 }

@command("add", desc="Sumar dos números")
fn add(a: Int, b: Int) -> Int { print("{a + b}"); return 0 }

@command("status", desc="Chequear estado del servicio")
async fn status(url: Str = "http://localhost:8080") -> Int {
    // ... llamada HTTP a la URL ...
    return 0
}

$ ./mybin --help
COMMANDS:
    greet     Saludar a una persona
    add       Sumar dos números
    status    Chequear estado del servicio

$ ./mybin add 21 21
42

$ ./mybin status --url http://prod.example.com
✓ healthy

El dispatch se genera en build time. No hay tabla de lookup de comandos en runtime que mantener.

Async nativo, porque por qué no

El comando status de arriba es async. El compilador lo detecta y envuelve el dispatch en #[tokio::main] automáticamente:

@command("fetch", desc="Traer una URL e imprimir el body")
async fn fetch(url: Str) -> Int {
    // Asumí que `http.get` fuera built-in (todavía no lo es; esto es ilustrativo).
    let body = http.get(url).await?
    print(body)
    return 0
}

El mismo async/await que usás en handlers HTTP funciona en CLI commands. Sin boilerplate de asyncio.run(). Sin "este comando es async, ese otro no, por favor no mezcles". Solo async fn cuando lo querés.

Exit codes

Las CLI tools viven y mueren por exit codes. La convención es POSIX:

  • 0 — éxito.
  • 1+ — retornado por el handler explícitamente.
  • 2 — error de parsing del CLI (flag desconocida, type incorrecto, positional faltante).
@command("validate", desc="Chequear un archivo")
fn validate(path: Str) -> Int {
    let contents = read_file(path)
    if (contents.starts_with("FAIL")) {
        print("validación falló")
        return 1   // distinto de error interno
    }
    return 0
}

$ ./mybin validate ok.txt
$ echo $?
0

$ ./mybin validate fail.txt
validación falló
$ echo $?
1

$ ./mybin validate
✗ greet: missing positional argument `<path>`
$ echo $?
2

El parser CLI maneja los errores de parsing. Tu código maneja los errores de negocio. Limpio.

El poder completo del lenguaje

Acá es donde el approach de Fitz paga en una forma que typer no puede: tenés el lenguaje entero a tu disposición en CLI tools, no solo funciones y prints.

CLI tools con el ORM

¿Necesitás un CLI de admin de DB? Es el mismo ORM que el servicio HTTP:

@command("list-users", desc="Imprimir todos los users")
async fn list_users(db: DbConn) -> Int {
    let users = User.all(db).await
    for u in users {
        print("#{u.id}\t{u.email}\t{u.role}")
    }
    return 0
}

@command("delete-user", desc="Borrar un user por email")
async fn delete_user(db: DbConn, email: Str, force: Bool = false) -> Int {
    if not force {
        print("Usá --force para borrar de verdad")
        return 1
    }
    User.where(fn(u) => u.email == email).delete(db).await
    print("borrado")
    return 0
}

La inyección de DbConn funciona igual que en handlers HTTP. Closure-to-SQL en .where(...) funciona. Eager loading funciona. Las migraciones de fitz db diff/migrate funcionan. El CLI tool tiene el mismo acceso a tu capa de datos que el API server, con la misma seguridad de tipos.

CLI con llamadas HTTP

¿Querés un CLI que hable con tu propio API? Mismo lenguaje, sin SDK separado:

@command("ping-prod", desc="Pegarle al /healthz de prod")
async fn ping_prod() -> Int {
    let url = env_or("PROD_URL", "https://api.example.com")
    // ... usá la stdlib o `from python import requests` etc ...
    return 0
}

CLI como wrapper de herramientas Python

¿Necesitás envolver una herramienta Python pero con mejor UX? El interop Python está en Fitz:

from python import subprocess

@command("backup-db", desc="Correr pg_dump y subir a S3")
async fn backup_db(db_url: Str, bucket: Str) -> Int {
    let dump_cmd = "pg_dump {db_url} > backup.sql"
    subprocess.run(dump_cmd, shell=true).await?
    // ... upload a S3 ...
    return 0
}

El CLI está en Fitz. La llamada a pg_dump es shell. El upload a S3 podría ser Python con boto3 (from python import boto3). Un binario, tres ecosistemas compuestos.

CLI con config + secrets

El mismo Secret<T> y config(...) de la Parte 3 funcionan en CLI tools:

@command("deploy", desc="Empujar un release")
async fn deploy(env: Str = "staging") -> Int {
    let api_key: Secret<Str> = secret("DEPLOY_API_KEY")
    let endpoint: Str = config("DEPLOY_ENDPOINT", "https://deploy.internal")
    // ... usá api_key.expose() en el request ...
    return 0
}

api_key nunca leakea a logs incluso si el path de error del comando deploy imprime el config map. Las mismas reglas de redacción de los servicios HTTP aplican acá.

Boilerplate cli-tool

El repo tiene un boilerplate para proyectos CLI en boilerplates/cli-tool/. Trae tres comandos como starter:

  • report — genera un sumario de datos.
  • count — cuenta items.
  • regions — lista categorías.
fitz new my-cli --template cli-tool
cd my-cli
fitz dev

Hot reload también funciona en CLI mode — fitz dev watchea el source, mata y respawnea cuando guardás.

Lo que no está en la caja

  • Prompts interactivos (pensá inquirer / click.prompt). Fitz todavía no tiene readers de stdin estilo read_line en el core. Por ahora, aceptá una flag y alimentala vía env o stdin piped.
  • TUI (terminal UI con control de cursor). Fuera de scope.
  • Generación de shell completion (bash/zsh/fish). No se genera automático todavía. El approach del archivo _complete escrito a mano sigue funcionando.
  • --no-foo para flags Bool = true. Bools default a false; si querés una flag que default a true y vos opt-out, la convención es invertir el booleano en tu lógica de negocio por ahora. Trackeada como deuda menor.

Si algo de esto te bloquea, abrí un issue. O son chicos para agregar o ya están en progreso.

Por qué importa

Cada developer que construye servicios web también termina escribiendo CLI tools. Migraciones para correr, imports ad-hoc, smoke tests, scripts de deploy, acciones admin, exports de data. La elección hoy en la mayoría de los lenguajes es:

  • Mismo lenguaje que el servicio, con una librería CLI separada (Python: typer).
  • Bash / shell script que llama a tu servicio vía HTTP (perdés toda la seguridad de tipos).
  • Un lenguaje separado para ops (binarios Go al lado de un servicio Python — está bien, pero dos lenguajes para mantener).

Fitz propone una cuarta: mismo compilador, mismo type checker, mismo ORM, mismo async, mismo formato de binario. Tus CLI tools viven en el mismo repo, comparten el mismo type User, le pegan al mismo Postgres con la misma lógica de conexión.

Podés escribir mybin migrate y mybin reset-test-db en el mismo archivo .fitz que tus handlers @get("/users") si querés. O dividir en comandos separados por binario. La elección es tuya, no de la librería.

Probalo:

# Linux / macOS / WSL
curl -sSf https://thegreekman76.github.io/fitz/install.sh | sh

# Windows (PowerShell)
irm https://thegreekman76.github.io/fitz/install.ps1 | iex

# Reabrí la terminal, después:
fitz new micli --template cli-tool
cd micli
fitz run main.fitz greet --help
fitz build
./micli greet Ada --loud --count 3

Para VSCode (recomendado para editar — hover con tipos, autocomplete, signature help): bajá el fitz-lang-<plataforma>.vsix desde la página de releases y code --install-extension fitz-lang-<plataforma>.vsix --force. El Language Server viene incluido.

Vas a tener un binario nativo self-contained en tu pwd en menos de cinco minutos.

Repo: github.com/Thegreekman76/fitz
Boilerplate cli-tool: github.com/Thegreekman76/fitz/tree/main/boilerplates/cli-tool
Docs y curso: thegreekman76.github.io/fitz
Capítulo de la guía sobre CLI: thegreekman76.github.io/fitz/guide/#33-cli
Roadmap: docs/roadmap.md
CHANGELOG: CHANGELOG.md
Issues: github.com/Thegreekman76/fitz/issues

Hasta la próxima.