Skip to content

Commit 5bc1b4b

Browse files
authored
Revise completions plugin documentation
Updated the plugin-completions documentation for clarity and consistency, including improved usage examples and feature descriptions.
1 parent b97a338 commit 5bc1b4b

1 file changed

Lines changed: 28 additions & 45 deletions

File tree

docs/official-plugins/plugin-completions.md

Lines changed: 28 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ title: Completions Plugin
33
---
44

55
# @clerc/plugin-completions
6-
7-
A plugin that adds command-line auto-completion functionality to your CLI. Based on [@bomb.sh/tab](https://github.com/bombshell-dev/tab).
6+
A plugin to add command-line autocompletion functionality to your CLI, based on [@bomb.sh/tab](https://github.com/bombshell-dev/tab).
87

98
## 📦 Installation
109

1110
:::code-group
12-
1311
```sh [npm]
1412
$ npm install @clerc/plugin-completions
1513
```
@@ -21,7 +19,6 @@ $ yarn add @clerc/plugin-completions
2119
```sh [pnpm]
2220
$ pnpm add @clerc/plugin-completions
2321
```
24-
2522
:::
2623

2724
## 🚀 Usage
@@ -30,7 +27,7 @@ $ pnpm add @clerc/plugin-completions
3027

3128
```ts
3229
import { completionsPlugin } from "@clerc/plugin-completions";
33-
// or import directly from clerc
30+
// Or import directly from clerc
3431
import { completionsPlugin } from "clerc";
3532
```
3633

@@ -41,12 +38,12 @@ const cli = Clerc.create()
4138
.scriptName("my-cli")
4239
.description("My CLI application")
4340
.version("1.0.0")
44-
.use(completionsPlugin()) // Add auto-completion plugin
45-
.command("start", "Start service")
41+
.use(completionsPlugin()) // Add the autocompletion plugin
42+
.command("start", "Start the service")
4643
.on("start", (ctx) => {
4744
console.log("Service started");
4845
})
49-
.command("stop", "Stop service")
46+
.command("stop", "Stop the service")
5047
.on("stop", (ctx) => {
5148
console.log("Service stopped");
5249
})
@@ -56,58 +53,44 @@ const cli = Clerc.create()
5653
### Running Effect
5754

5855
```bash
59-
# Generate auto-completion script for Bash
60-
$ node my-cli completions bash
56+
# Generate autocompletion script for Bash
57+
$ my-cli completions bash
6158

62-
# Execute directly to enable auto-completion
59+
# Execute directly to enable autocompletion
6360
# PowerShell
64-
node my-cli completions pwsh | Out-String | Invoke-Expression
61+
$ my-cli completions powershell | Out-String | Invoke-Expression
6562

6663
# Bash
67-
eval "$(node my-cli completions bash)"
64+
$ eval "$(my-cli completions bash)"
6865

6966
# Zsh
70-
eval "$(node my-cli completions zsh)"
67+
$ eval "$(my-cli completions zsh)"
7168

7269
# You can also specify the shell type with the --shell parameter
73-
eval "$(node my-cli completions --shell bash)"
74-
75-
# Or install directly
76-
$ node my-cli completions install bash
77-
78-
# Uninstall
79-
$ node my-cli completions uninstall
70+
$ eval "$(my-cli completions --shell bash)"
8071
```
8172

8273
## 📝 Features
8374

84-
### Auto-generate Completion Scripts
75+
### Automatic Completion Script Generation
76+
The plugin automatically generates a full autocompletion script for your CLI, supporting:
77+
- Command name autocompletion
78+
- Option name autocompletion
8579

86-
The plugin automatically generates complete auto-completion scripts for your CLI, supporting:
80+
### Completion Logic
8781

88-
- Command name completion
89-
- Option name completion
82+
```sh
83+
$ my-cli <TAB> # Complete available commands
84+
$ my-cli command <TAB> # Complete subcommands of the specified command
85+
$ my-cli -<TAB> # Complete all global short options, e.g., -h, -V
86+
$ my-cli --<TAB> # Complete all global long options
87+
$ my-cli command -<TAB> # Complete short options for the specified command (including global options), e.g., -h, -V
88+
$ my-cli command --<TAB> # Complete all available options for the specified command, including global options
89+
```
9090

9191
### Supported Shells
9292

9393
- **Bash** - Default shell for Linux and macOS
94-
- **Zsh** - Default shell for macOS Catalina and later
95-
- **Fish** - Modern shell
96-
- **PowerShell**(pwsh) - Default shell for Windows
97-
98-
## 🎨 Custom Configuration
99-
100-
### Advanced Configuration
101-
102-
```ts
103-
const cli = Clerc.create()
104-
.scriptName("my-cli")
105-
.description("My CLI application")
106-
.version("1.0.0")
107-
.use(
108-
completionsPlugin({
109-
managementCommands: false, // Don't generate install/uninstall commands
110-
}),
111-
)
112-
.parse();
113-
```
94+
- **Zsh** - Default shell for macOS Catalina and later versions
95+
- **Fish** - A modern shell
96+
- **PowerShell** - Default shell for Windows

0 commit comments

Comments
 (0)