bunli dev command runs your CLI in development mode with hot reload, automatic type generation, and debugging support. It provides a fast feedback loop during development.
Usage
Basic Example
Options
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--entry | -e | string | auto-detect | Entry file (defaults to auto-detect) |
--generate | - | boolean | true | Enable codegen |
--clear-screen | - | boolean | true | Clear screen on reload |
--watch | -w | boolean | true | Watch for changes |
--inspect | -i | boolean | false | Enable debugger |
--port | -p | number | - | Debugger port |
Hot Reload
The dev command uses Bun’s native hot reload feature (--hot) to automatically restart your CLI when source files change:
Watch Patterns
The dev command automatically determines which directory to watch for changes:- Configured
commands.directoryinbunli.config.ts ./commandsdirectory if it exists./src/commandsdirectory if it exists- Directory containing the entry file
./srcdirectory if it exists
Automatic Type Generation
When codegen is enabled (default), the dev command automatically generates TypeScript type definitions for your commands:File Watcher for Type Regeneration
The dev command watches your commands directory for changes and automatically regenerates types:.ts, .tsx, .js, and .jsx files trigger regeneration. Generated files (.bunli/commands.gen.ts) are automatically excluded.
Debugging
Enable Node.js debugger with the--inspect flag:
--inspect flag to the Bun process:
Configuration
Configure dev mode inbunli.config.ts:
Output Example
Disabling Features
Disable Type Generation
Disable Watch Mode
Disable Screen Clearing
Advanced Usage
Custom Entry Point
Passing Arguments to CLI
All positional arguments after the dev command options are passed to your CLI:Environment Variables
The dev command sets theNODE_ENV environment variable to development:
Signal Handling
The dev command properly handlesSIGINT (Ctrl+C) and SIGTERM signals:
Troubleshooting
No Entry File Found
If you see “No entry file found”, specify the entry file explicitly:bunli.config.ts:
Type Generation Failures
If type generation fails, check:- Your entry file exports a CLI created with
createCLI() - All commands are properly imported and registered
- Commands are defined using
defineCommand()
File Watcher Not Working
If the file watcher doesn’t detect changes:- Ensure the commands directory exists
- Set
commands.directoryexplicitly inbunli.config.ts - Check file system permissions
See Also
- Building - Build your CLI for production
- Testing - Run tests during development
- Type Generation - Manual type generation command