Commit Graph

47 Commits

Author SHA1 Message Date
robobun
f9a042f114 Improve --reporter flag help and error messages (#22900)
## Summary
- Clarifies help text for `--reporter` and `--reporter-outfile` flags
- Improves error messages when invalid reporter formats are specified
- Makes distinction between test reporters and coverage reporters
clearer

## Changes
1. Updated help text in `Arguments.zig` to better explain:
   - What formats are currently available (only 'junit' for --reporter)
   - Default behavior (console output for tests)
   - Requirements (--reporter-outfile needed with --reporter=junit)
   
2. Improved error messages to list available options when invalid
formats are used

3. Updated CLI completions to match the new help text

## Test plan
- [x] Built and tested with `bun bd`
- [x] Verified help text displays correctly: `./build/debug/bun-debug
test --help`
- [x] Tested error message for invalid reporter:
`./build/debug/bun-debug test --reporter=json`
- [x] Tested error message for missing outfile: `./build/debug/bun-debug
test --reporter=junit`
- [x] Tested error message for invalid coverage reporter:
`./build/debug/bun-debug test --coverage-reporter=invalid`
- [x] Verified junit reporter still works: `./build/debug/bun-debug test
--reporter=junit --reporter-outfile=/tmp/junit.xml`
- [x] Verified lcov coverage reporter still works:
`./build/debug/bun-debug test --coverage --coverage-reporter=lcov`

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
2025-09-24 18:26:37 -07:00
pfg
0d6a27d394 Remove remnants of '--only' flag in documentation (#22168) 2025-09-22 16:07:44 -07:00
robobun
0bf0d8420e Add comprehensive CLI flag parser for shell completions (#21604)
## Summary

This PR adds a comprehensive TypeScript CLI flag parser that reads the
`--help` menu for every Bun command and generates structured JSON data
for shell completion generators.

### Features

- **🔍 Complete command discovery**: Automatically discovers all 22 Bun
commands
- **📋 Comprehensive flag parsing**: Extracts 388+ flags with
descriptions, types, defaults, and choices
- **🌳 Nested subcommand support**: Handles complex cases like `bun pm
cache rm`, `bun pm pkg set`
- **🔗 Command aliases**: Supports `bun i` = `bun install`, `bun a` =
`bun add`, etc.
- **🎯 Dynamic completions**: Integrates with `bun getcompletes` for
scripts, packages, files, binaries
- **📂 File type awareness**: Knows when to complete `.js/.ts` files vs
test files vs packages
- ** Special case handling**: Handles bare `bun` vs `bun run` and other
edge cases

### Generated Output

The script generates `completions/bun-cli.json` with:
- 21 commands with full metadata
- 47 global flags 
- 16 pm subcommands (including nested ones)
- 54+ examples
- Dynamic completion hints
- Integration info for existing shell completions

### Usage

```bash
bun run scripts/generate-cli-completions.ts
```

Output saved to `completions/bun-cli.json` for use by future shell
completion generators.

### Perfect Shell Completions Ready

This JSON structure provides everything needed to generate perfect shell
completions for fish, bash, and zsh with full feature parity to the
existing hand-crafted completions. It captures all the complex cases
that make Bun's CLI completions work seamlessly.

The generated data structure includes:
- Context-aware flag suggestions
- Proper file type filtering
- Package name completions
- Script and binary discovery
- Subcommand nesting
- Alias handling
- Dynamic completion integration

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
2025-08-07 15:38:35 -07:00
Michael H
764e20ee19 implement bun pm version (#20706) 2025-07-02 18:54:47 -07:00
pagal
2482af60d5 Added missing completion info for: bun update (#20316) 2025-06-15 13:20:35 -07:00
nobkd
6edc3a9900 remove audit from bun pm help (#20167) 2025-06-03 14:37:03 -07:00
Meghan Denny
8759527feb zsh: fix syntax error in bun audit completion 2025-05-27 19:51:18 -07:00
Alistair Smith
9e329ee605 bun pm audit (#19855) 2025-05-23 22:31:12 -07:00
tsingkwai
7830e15650 Added command: publish to fish completions (#16593) 2025-01-23 05:15:35 -08:00
Lucas Garron
b901ff2b52 Fix fish completion description for bun install --no-save (#15456)
Co-authored-by: Michael H <git@riskymh.dev>
2025-01-19 22:44:30 +11:00
Michael H
193a6306d5 Implement bun add --peer <pkg> (#16150) 2025-01-06 12:59:59 -08:00
Yuto Ogino
dd32e6b416 Fix zsh auto-completion for package.json scripts with name containing colons (#15619) 2024-12-06 10:53:43 -08:00
Dylan Conway
1a9307da08 bun outdated docs (#13497)
Co-authored-by: Zack Radisic <zack@theradisic.com>
2024-08-23 23:11:52 -07:00
Ivan Baksheev
20235a0d22 Add packages option to remove all dependencies from bundle (#12562) 2024-07-14 15:20:27 -07:00
Bjön Limell
b01f67857f Added missing commands to bun.bash (#7181) 2024-07-09 16:15:34 -07:00
Parmar Jai Atul
b49853c24f Fix an ambiguous redirect in bun bash-completions (#11468) 2024-05-30 15:11:12 -07:00
janos-r
b2c697296e Fix bun.fish completions (#11450) 2024-05-29 16:59:13 -07:00
Peter Ammon
ee13aabded Optimize fish completions (#11185) 2024-05-19 18:31:05 -07:00
sequencerr
21ec6669df Fix bun description (#9345) 2024-03-10 10:19:38 -07:00
chocolateboy
ab95e2189f Prevent shell-option changes leaking out of the bash-completion script (#7646)
- save and restore `globstar` rather than leaving it unset
  - don't change `extglob` as it's already defined and required by
    bash-completion
2023-12-13 17:32:53 -08:00
mimikun
3c97f568a7 Fix typos (#7378) 2023-11-30 18:36:44 -08:00
Otger Rogla
eaa9ba99fa add support for --env-file arg to bun run to load custom env files (#7032) 2023-11-11 02:10:47 -08:00
Ai Hoshino
92a5d845ae chore: Update ZSH completions (#4428) 2023-09-21 17:43:01 -07:00
Nathan Hammond
8ae9aeea6b Remove the ability to configure lockfile. (#5335) 2023-09-13 22:32:03 -07:00
Colin McDonnell
78081cbb40 Support --dev/-D and support more flags on bun install (#3989) 2023-08-04 20:41:16 -07:00
Tiago Teixeira
d8817c2d32 Add support for install with --frozen-lockfile (#3365)
* Add support for install with --frozen-lockfile

* Add test

* Add test for frozenLockfile in config file
2023-06-25 16:43:39 -07:00
dave caruso
96e113f41c bundler tests: rest of default.test.ts and starting jsx tests (#2765) 2023-04-28 21:08:48 -07:00
Jackson Kearl
4dd4bab7b9 Support directories in ZSH run completions (#2425)
* Support scripts in dirs in zsh run completions

* add back wasm support
2023-03-20 11:27:39 -07:00
Jarred Sumner
f6a62c01bf Cherry-pick #1638
Closes #1638
2022-12-23 00:59:41 -08:00
Jarred Sumner
979074de2b Prevent running compinit twice 2022-12-23 00:50:19 -08:00
Colin McDonnell
e6c2f48895 Add filename completions on naked bun command (#1593)
Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2022-12-08 17:32:25 -08:00
Jarred Sumner
58fe024aea Add --hot to completions 2022-10-12 19:07:11 -07:00
Jarred Sumner
bcdc68ac94 Add bun link and bun unlink to completions 2022-08-10 23:09:07 -07:00
Jarred Sumner
d034c004f9 Implement bun init subcommand 2022-08-04 21:42:49 -07:00
Victory Osikwemhe
8a43083415 Support for completion in Bash (#403)
* Add bash completions for optional flags (long and short options)

* extend bash completion to support options with specific requirements

* fix: remove global variables

* fix: rename cur_file to cur_word

* add c,rm,i aliases

* fix: add --help flag to create alias

* fix: --loader options bug

* fix --backend and linting

* linting

* add support for file completion for `bun run` as well as few changes also

* chore(): use _ as prefix for function names

* fix undefined function

* feat(wip): implement installation for bash bun completion in zig

* fix(): use separate paths instead of slice of paths

* rename _bun.bash to bun.completion.bash for compatability with  oh-my-bash

* change `bun.completion.bash` to filename
2022-07-25 00:47:34 -07:00
Alexander Kuznetsov
5d8a99e1d4 Group zsh completion options by type (#194) 2022-06-20 06:30:32 -07:00
Jarred Sumner
611cdd69b1 Add bun -g to completions 2022-02-12 01:21:44 -08:00
luke miles
7f33846005 copy: replace Bun with bun (#99)
Most CLI tools have the style convention of referring to themselves in
lowercase. It is, after all, the name that users type in when using
the tool. This PR maintains that convention in bun.

"Drop the uppercase B, it's cleaner"
2022-01-02 03:09:51 -08:00
Jarred Sumner
a0551a9b8b Autocomplete popular package names (thanks @evanwashere) 2021-12-19 23:30:25 -08:00
Jarred Sumner
394335fa91 Update bun.fish 2021-12-18 23:06:07 -08:00
Jarred Sumner
8125c05be0 Update fish completions 2021-12-18 23:04:31 -08:00
Jarred Sumner
059f01d23a Add new zsh completions 2021-12-18 21:44:17 -08:00
Jarred Sumner
bc3c17ffc8 Improve ZSH completions 2021-11-07 02:41:26 -08:00
Jarred Sumner
13582981e4 Update bun.fish 2021-11-05 01:15:35 -07:00
Jarred Sumner
1676af9de9 [cli] Slightly improve zsh completions 2021-11-01 04:41:46 -07:00
Jarred Sumner
173724b402 [CLI] Add zsh completions and auto-install completions 2021-11-01 03:43:27 -07:00
Jarred Sumner
64d3927879 [CLI] Add completions for Fish 2021-10-31 21:02:15 -07:00