You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-15Lines changed: 17 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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`
3
3
4
4
# tab
5
+
5
6
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
6
7
7
8
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.
8
9
9
10
Tab solves this complexity by providing autocompletions that work consistently across `zsh`, `bash`, `fish`, and `powershell`.
10
11
11
-
12
12
### Installation
13
13
14
14
```bash
@@ -36,11 +36,12 @@ npx @bomb.sh/tab bun powershell >> $PROFILE
36
36
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)
37
37
38
38
**Example in action:**
39
+
39
40
```bash
40
41
pnpm install --reporter=<TAB>
41
42
# Shows append-only, default, ndjson, silent
42
43
43
-
npm remove <TAB>
44
+
npm remove <TAB>
44
45
# Shows the packages from package.json
45
46
46
47
yarn add --emoji=<TAB>
@@ -77,25 +78,27 @@ if (process.argv[2] === 'complete') {
77
78
```
78
79
79
80
**Test your completions:**
81
+
80
82
```bash
81
83
node my-cli.js complete -- dev --p<TAB>
82
84
# Output: --port Specify port
83
85
84
-
node my-cli.js complete -- dev --port=<TAB>
86
+
node my-cli.js complete -- dev --port=<TAB>
85
87
# Output: --port=3000 Development port
86
88
# --port=8080 Production port
87
89
```
88
90
89
91
**Install for users:**
92
+
90
93
```bash
91
94
# One-time setup
92
95
source<(my-cli complete zsh)
93
96
94
-
# Permanent setup
97
+
# Permanent setup
95
98
my-cli complete zsh >>~/.zshrc
96
99
```
97
100
98
-
## Framework Adapters
101
+
## Framework Adapters
99
102
100
103
Tab provides adapters for popular JavaScript CLI frameworks.
101
104
@@ -108,9 +111,10 @@ import tab from '@bomb.sh/tab/cac';
108
111
const cli =cac('my-cli');
109
112
110
113
// 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');
114
118
115
119
// Initialize tab completions
116
120
const completion =tab(cli);
@@ -202,10 +206,8 @@ for (const command of completion.commands.values()) {
202
206
program.parse();
203
207
```
204
208
205
-
206
209
Tab's package manager completions are dynamically generated from the actual help output of each tool:
207
210
208
-
209
211
Tab uses a standardized completion protocol that any CLI can implement:
0 commit comments