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
+20-10Lines changed: 20 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Tools like git and their autocompletion experience inspired us to build this too
9
9
```ts
10
10
import { Completion, script } from"@bombsh/tab";
11
11
12
-
const name ="vite"
12
+
const name ="my-cli"
13
13
const completion =newCompletion()
14
14
15
15
completion.addCommand("start", "Start the application", async (previousArgs, toComplete, endsWithSpace) => {
@@ -48,7 +48,7 @@ if (process.argv[2] === "--") {
48
48
}
49
49
```
50
50
51
-
Now your user can run `source <(vite complete zsh)` and they will get completions for the `vite` command using the [autocompletion server](#autocompletion-server).
51
+
Now your user can run `source <(my-cli complete zsh)` and they will get completions for the `my-cli` command using the [autocompletion server](#autocompletion-server).
52
52
53
53
## Adapters
54
54
@@ -60,7 +60,7 @@ Since we are heavy users of tools like `cac` and `citty`, we have created adapte
Now autocompletion will be available for any specified command and option in your cac instance. If your user writes `vite dev --po`, they will get suggestions for the `--port` option. Or if they write `vite d` they will get suggestions for the `dev` command.
85
+
Now autocompletion will be available for any specified command and option in your cac instance. If your user writes `my-cli dev --po`, they will get suggestions for the `--port` option. Or if they write `my-cli d` they will get suggestions for the `dev` command.
86
86
87
87
Suggestions are missing in the adapters since yet cac or citty do not have a way to provide suggestions (tab just came out!), we'd have to provide them manually. Mutations do not hurt in this situation.
88
88
@@ -94,8 +94,8 @@ import tab from "@bombsh/tab/citty";
By integrating tab into your cli, your cli would have a new command called `complete`. This is where all the magic happens. And the shell would contact this command to get completions. That's why we call it the autocompletion server.
137
148
138
149
```zsh
139
-
vitecomplete -- --po
150
+
my-clicomplete -- --po
140
151
--port Specify the port number
141
152
:0
142
153
```
143
154
144
155
The autocompletion server can be a standard to identify whether a package provides autocompletions. Whether running `tool complete --` would result in an output that ends with `:{Number}` (matching the pattern `/:\d+$/`).
145
156
146
-
In situations like `vite dev --po` you'd have autocompletions! But in the case of `pnpm vite dev --po` which is what most of us use, tab does not inject autocompletions for a tool like pnpm.
157
+
In situations like `my-cli dev --po` you'd have autocompletions! But in the case of `pnpm my-cli dev --po` which is what most of us use, tab does not inject autocompletions for a tool like pnpm.
147
158
148
159
Since pnpm already has its own autocompletion [script](https://pnpm.io/completion), this provides the opportunity to check whether a package provides autocompletions and use those autocompletions if available.
149
160
@@ -153,8 +164,7 @@ Other package managers like `npm` and `yarn` can decide whether to support this
0 commit comments