Skip to content

Commit 36de8cd

Browse files
committed
pretteir
1 parent 36d5b2e commit 36de8cd

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
> A video showcasing how pnpm autocompletions work on a test CLI command
2-
like `my-cli`
1+
> A video showcasing how pnpm autocompletions work on a test CLI command
2+
> like `my-cli`
33
44
# tab
5+
56
Shell autocompletions are largely missing in the JavaScript CLI ecosystem. This tool bridges that gap by autocompletions for `pnpm`, `npm`, `yarn`, and `bun` with dynamic option parsing and context-aware suggestions and also Easy-to-use adapters for popular JavaScript CLI frameworks like CAC, Citty, and Commander.js
67

78
As CLI tooling authors, if we can spare our users a second or two by not checking documentation or writing the `-h` flag, we're doing them a huge favor. The unconscious mind loves hitting the [TAB] key and always expects feedback. When nothing happens, it breaks the user's flow - a frustration apparent across the whole JavaScript CLI tooling ecosystem.
89

910
Tab solves this complexity by providing autocompletions that work consistently across `zsh`, `bash`, `fish`, and `powershell`.
1011

11-
1212
### Installation
1313

1414
```bash
@@ -36,11 +36,12 @@ npx @bomb.sh/tab bun powershell >> $PROFILE
3636
You'd get smart completions for all commands and options, and dynamic option values e.g., `--reporter=<TAB>`. and its always up-to-date (parsed from live help output)
3737

3838
**Example in action:**
39+
3940
```bash
4041
pnpm install --reporter=<TAB>
4142
# Shows append-only, default, ndjson, silent
4243

43-
npm remove <TAB>
44+
npm remove <TAB>
4445
# Shows the packages from package.json
4546

4647
yarn add --emoji=<TAB>
@@ -77,25 +78,27 @@ if (process.argv[2] === 'complete') {
7778
```
7879

7980
**Test your completions:**
81+
8082
```bash
8183
node my-cli.js complete -- dev --p<TAB>
8284
# Output: --port Specify port
8385

84-
node my-cli.js complete -- dev --port=<TAB>
86+
node my-cli.js complete -- dev --port=<TAB>
8587
# Output: --port=3000 Development port
8688
# --port=8080 Production port
8789
```
8890

8991
**Install for users:**
92+
9093
```bash
9194
# One-time setup
9295
source <(my-cli complete zsh)
9396

94-
# Permanent setup
97+
# Permanent setup
9598
my-cli complete zsh >> ~/.zshrc
9699
```
97100

98-
## Framework Adapters
101+
## Framework Adapters
99102

100103
Tab provides adapters for popular JavaScript CLI frameworks.
101104

@@ -108,9 +111,10 @@ import tab from '@bomb.sh/tab/cac';
108111
const cli = cac('my-cli');
109112

110113
// Define your CLI
111-
cli.command('dev', 'Start dev server')
112-
.option('--port <port>', 'Specify port')
113-
.option('--host <host>', 'Specify host');
114+
cli
115+
.command('dev', 'Start dev server')
116+
.option('--port <port>', 'Specify port')
117+
.option('--host <host>', 'Specify host');
114118

115119
// Initialize tab completions
116120
const completion = tab(cli);
@@ -202,10 +206,8 @@ for (const command of completion.commands.values()) {
202206
program.parse();
203207
```
204208

205-
206209
Tab's package manager completions are dynamically generated from the actual help output of each tool:
207210

208-
209211
Tab uses a standardized completion protocol that any CLI can implement:
210212

211213
```bash
@@ -217,13 +219,13 @@ my-cli complete -- install --port=""
217219
```
218220

219221
**Output Format:**
222+
220223
```
221224
--port=3000 Development port
222-
--port=8080 Production port
225+
--port=8080 Production port
223226
:4
224227
```
228+
225229
## Contributing
226230

227231
We welcome contributions! Tab's architecture makes it easy to add support for new package managers or CLI frameworks.
228-
229-

0 commit comments

Comments
 (0)