0
# CLI Commands
1
2
Bunli provides a comprehensive command-line interface for developing, building, testing, and releasing CLI applications. All commands support help flags and colorized output with progress indicators.
3
4
## Capabilities
5
6
### Development Command
7
8
Run CLI applications in development mode with hot reload and debugging support.
9
10
```bash { .api }
11
bunli dev [options]
12
# Aliases: bunli d
13
14
# Options:
15
--entry, -e <file> # Entry file (defaults to auto-detect)
16
--watch, -w # Watch for changes (default: true)
17
--inspect, -i # Enable debugger (default: false)
18
--port, -p <number> # Debugger port (default: 9229)
19
--help # Show command help
20
```
21
22
**Usage Examples:**
23
24
```bash
25
# Basic development with auto-detected entry
26
bunli dev
27
28
# Specify entry file and enable debugging
29
bunli dev --entry src/my-cli.ts --inspect
30
31
# Run with custom debugger port
32
bunli dev --inspect --port 9230
33
34
# Disable file watching
35
bunli dev --no-watch
36
37
# Pass arguments to the CLI being developed
38
bunli dev -- --my-cli-arg value
39
```
40
41
### Build Command
42
43
Build CLI applications for production with optional compilation to standalone executables.
44
45
```bash { .api }
46
bunli build [options]
47
# Aliases: bunli b
48
49
# Options:
50
--entry, -e <file> # Entry file (defaults to auto-detect)
51
--outdir, -o <directory> # Output directory (default: ./dist)
52
--outfile <filename> # Output filename for single executable
53
--minify, -m # Minify output (default: true)
54
--sourcemap, -s # Generate sourcemaps (default: false)
55
--bytecode # Enable bytecode compilation (experimental)
56
--runtime, -r <bun|node> # Runtime target for non-compiled builds
57
--targets, -t <platforms> # Target platforms (comma-separated)
58
--watch, -w # Watch for changes (default: false)
59
--help # Show command help
60
```
61
62
**Target Platforms:**
63
64
- `native` - Current platform
65
- `all` - All supported platforms
66
- `darwin-arm64` - macOS Apple Silicon
67
- `darwin-x64` - macOS Intel
68
- `linux-arm64` - Linux ARM64
69
- `linux-x64` - Linux x86_64
70
- `windows-x64` - Windows x86_64
71
72
**Usage Examples:**
73
74
```bash
75
# Basic build
76
bunli build
77
78
# Build for specific platforms
79
bunli build --targets darwin-arm64,linux-x64,windows-x64
80
81
# Build for all platforms with compression
82
bunli build --targets all
83
84
# Traditional build (no compilation)
85
bunli build --runtime node --outdir lib
86
87
# Build with source maps and watch
88
bunli build --sourcemap --watch
89
90
# Experimental bytecode compilation
91
bunli build --targets native --bytecode
92
```
93
94
### Test Command
95
96
Run tests for CLI applications with coverage and watch mode support.
97
98
```bash { .api }
99
bunli test [options]
100
# Aliases: bunli t
101
102
# Options:
103
--pattern, -p <patterns> # Test file patterns (default: **/*.test.ts)
104
--watch, -w # Watch for changes (default: false)
105
--coverage, -c # Generate coverage report (default: false)
106
--bail, -b # Stop on first failure (default: false)
107
--timeout <ms> # Test timeout in milliseconds
108
--all # Run tests in all packages (workspace mode)
109
--help # Show command help
110
```
111
112
**Usage Examples:**
113
114
```bash
115
# Run all tests
116
bunli test
117
118
# Run specific test patterns
119
bunli test --pattern "**/*.unit.test.ts,**/*.integration.test.ts"
120
121
# Run tests with coverage
122
bunli test --coverage
123
124
# Watch mode with bail on first failure
125
bunli test --watch --bail
126
127
# Run tests in all workspace packages
128
bunli test --all
129
130
# Set custom timeout
131
bunli test --timeout 30000
132
```
133
134
### Release Command
135
136
Create releases with version management, npm publishing, and GitHub releases.
137
138
```bash { .api }
139
bunli release [options]
140
# Aliases: bunli r
141
142
# Options:
143
--version, -v <version> # Version to release (patch/minor/major/x.y.z)
144
--tag, -t <format> # Git tag format (default: v${version})
145
--npm # Publish to npm (default: true)
146
--github # Create GitHub release (default: true)
147
--dry, -d # Dry run - show what would be done
148
--all # Release all packages (workspace mode)
149
--help # Show command help
150
```
151
152
**Version Strategies:**
153
154
- `patch` - Increment patch version (1.0.0 → 1.0.1)
155
- `minor` - Increment minor version (1.0.0 → 1.1.0)
156
- `major` - Increment major version (1.0.0 → 2.0.0)
157
- `x.y.z` - Explicit version number
158
159
**Usage Examples:**
160
161
```bash
162
# Interactive release with version selection
163
bunli release
164
165
# Patch release
166
bunli release --version patch
167
168
# Specific version
169
bunli release --version 2.1.0
170
171
# Dry run to preview changes
172
bunli release --dry
173
174
# Release without GitHub release
175
bunli release --no-github
176
177
# Custom tag format
178
bunli release --tag "release-${version}"
179
180
# Workspace release (all packages)
181
bunli release --all
182
```
183
184
### Initialization Command
185
186
Initialize new Bunli CLI projects with templates and package manager selection.
187
188
```bash { .api }
189
bunli init [options] [name]
190
# Aliases: bunli i
191
192
# Options:
193
--name, -n <name> # Project name
194
--template, -t <template> # Project template (default: basic)
195
--dir, -d <directory> # Directory to create project in
196
--git, -g # Initialize git repository (default: true)
197
--install # Install dependencies (default: true)
198
--package-manager, -p <pm> # Package manager (default: bun)
199
--help # Show command help
200
```
201
202
**Available Templates:**
203
204
- `basic` - Simple CLI project with minimal setup
205
- `advanced` - Advanced CLI with multiple commands and utilities
206
- `monorepo` - Multi-package workspace setup
207
208
**Package Managers:**
209
210
- `bun` (default) - Use Bun package manager
211
- `pnpm` - Use PNPM
212
- `yarn` - Use Yarn
213
- `npm` - Use npm
214
215
**Usage Examples:**
216
217
```bash
218
# Interactive initialization
219
bunli init
220
221
# Create named project
222
bunli init my-awesome-cli
223
224
# Advanced template with pnpm
225
bunli init --template advanced --package-manager pnpm my-cli
226
227
# Create in specific directory
228
bunli init --dir ./projects/cli-tools my-new-cli
229
230
# Skip git and dependencies
231
bunli init --no-git --no-install basic-cli
232
```
233
234
### Global Options
235
236
All commands support these global options:
237
238
```bash { .api }
239
--help, -h # Show help information
240
--version, -V # Show version information
241
```
242
243
### Command Aliases
244
245
All main commands have short aliases for convenience:
246
247
- `bunli d` → `bunli dev`
248
- `bunli b` → `bunli build`
249
- `bunli t` → `bunli test`
250
- `bunli r` → `bunli release`
251
- `bunli i` → `bunli init`
252
253
### Interactive Features
254
255
Commands provide rich interactive experiences:
256
257
- **Colored output** with status indicators
258
- **Progress spinners** for long-running operations
259
- **Interactive prompts** for missing required information
260
- **Confirmation dialogs** for destructive operations
261
- **Error handling** with helpful error messages and suggestions