Quick Start
Get a working CLI in under 5 minutes.
Install
Create a command
Bootstrap the CLI
Run it
Add middleware
Middleware wraps every command in an onion model -- each middleware can run logic before and after the handler. Here is a simple timing middleware:
Update the bootstrap to register it:
Every command now logs its execution time automatically.
Add configuration
maltty discovers and validates configuration files using Zod. Define a config schema and use module augmentation to type the config handle:
Register the config() middleware in cli():
Now update the command to load config lazily via the handle:
maltty will look for .my-app.jsonc, .my-app.json, and .my-app.yaml -- all validated against your Zod schema when load() is called.
Build for production
Install the maltty CLI tooling as a dev dependency and run the build command:
This produces an ESM bundle ready for distribution. See the Build a CLI guide for standalone binary output and advanced build options.
Next steps
- Build a CLI -- middleware, config, autoloading, and sub-exports
- Lifecycle -- how commands, middleware, and context fit together
- Add Authentication -- auth middleware and token storage