Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit d8cffb3

Browse files
committed
docs: inspector -> interceptor
1 parent 34ca1fb commit d8cffb3

4 files changed

Lines changed: 22 additions & 22 deletions

File tree

docs/.vitepress/config/en.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export const enConfig = defineConfig({
3232
link: "/commands",
3333
},
3434
{
35-
text: "Inspectors",
36-
link: "/inspectors",
35+
text: "Interceptors",
36+
link: "/interceptors",
3737
},
3838
{
3939
text: "Plugins",

docs/.vitepress/config/zh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const zhConfig = defineConfig({
3333
},
3434
{
3535
text: "检查器",
36-
link: "/zh/inspectors",
36+
link: "/zh/interceptors",
3737
},
3838
{
3939
text: "插件",
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
title: Inspectors
2+
title: Interceptors
33
---
44

5-
# Inspectors
5+
# Interceptors
66

7-
An inspector is a function that runs before or after calling the command handler, like middleware in koa.
7+
An interceptor is a function that runs before or after calling the command handler, like middleware in koa.
88

99
## Usage
1010

11-
Inspectors are added to the cli using the `inspector` method:
11+
Interceptors are added to the cli using the `interceptor` method:
1212

1313
```ts
1414
import { Clerc } from "clerc";
@@ -18,7 +18,7 @@ const cli = Clerc.create()
1818
.description("A simple cli")
1919
.version("1.0.0")
2020
.command("foo", "A foo command")
21-
.inspector((context, next) => {
21+
.interceptor((context, next) => {
2222
console.log("Before foo");
2323
// You can inject something into the context, or modify the context
2424
context.foo = "bar";
@@ -29,7 +29,7 @@ const cli = Clerc.create()
2929

3030
## Order
3131

32-
The inspector method accepts either a function or an object:
32+
The interceptor method accepts either a function or an object:
3333

3434
```ts
3535
import { Clerc } from "clerc";
@@ -39,7 +39,7 @@ const cli = Clerc.create()
3939
.description("A simple cli")
4040
.version("1.0.0")
4141
.command("foo", "A foo command")
42-
.inspector({
42+
.interceptor({
4343
enforce: "normal", // default, or 'pre', 'post'
4444
fn: (context, next) => {
4545
console.log("Before foo");
@@ -53,9 +53,9 @@ const cli = Clerc.create()
5353

5454
So the order of execution is:
5555

56-
1. Pre inspectors
57-
2. Normal inspectors
58-
3. Post inspectors
56+
1. Pre interceptors
57+
2. Normal interceptors
58+
3. Post interceptors
5959

6060
## Call after command handler
6161

@@ -69,7 +69,7 @@ const cli = Clerc.create()
6969
.description("A simple cli")
7070
.version("1.0.0")
7171
.command("foo", "A foo command")
72-
.inspector((context, next) => {
72+
.interceptor((context, next) => {
7373
console.log("Before foo");
7474
// You can inject something into the context, or modify the context
7575
context.foo = "bar";
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ title: 检查器
88

99
## 用法
1010

11-
可以使用 `inspector` 方法将检查器添加到命令行界面 (CLI) 中:
11+
可以使用 `interceptor` 方法将检查器添加到命令行界面 (CLI) 中:
1212

1313
```ts
1414
import { Clerc } from "clerc";
@@ -18,7 +18,7 @@ const cli = Clerc.create()
1818
.description("一个简单的命令行界面")
1919
.version("1.0.0")
2020
.command("foo", "一个 foo 命令")
21-
.inspector((context, next) => {
21+
.interceptor((context, next) => {
2222
console.log("在 foo 之前");
2323
// 您可以向上下文中添加一些内容,或修改上下文
2424
context.foo = "bar";
@@ -29,7 +29,7 @@ const cli = Clerc.create()
2929

3030
## 顺序
3131

32-
`inspector` 方法接受一个函数或一个对象:
32+
`interceptor` 方法接受一个函数或一个对象:
3333

3434
```ts
3535
import { Clerc } from "clerc";
@@ -39,7 +39,7 @@ const cli = Clerc.create()
3939
.description("一个简单的命令行界面")
4040
.version("1.0.0")
4141
.command("foo", "一个 foo 命令")
42-
.inspector({
42+
.interceptor({
4343
enforce: "normal", // 默认值,或者 'pre', 'post'
4444
fn: (context, next) => {
4545
console.log("在 foo 之前");
@@ -53,9 +53,9 @@ const cli = Clerc.create()
5353

5454
因此,执行顺序如下:
5555

56-
1. 预检查器(Pre inspectors
57-
2. 正常检查器(Normal inspectors
58-
3. 后检查器(Post inspectors
56+
1. 预检查器(Pre interceptors
57+
2. 正常检查器(Normal interceptors
58+
3. 后检查器(Post interceptors
5959

6060
## 在命令处理程序之后调用
6161

@@ -69,7 +69,7 @@ const cli = Clerc.create()
6969
.description("一个简单的命令行界面")
7070
.version("1.0.0")
7171
.command("foo", "一个 foo 命令")
72-
.inspector((context, next) => {
72+
.interceptor((context, next) => {
7373
console.log("在 foo 之前");
7474
// 您可以向上下文中添加一些内容,或修改上下文
7575
context.foo = "bar";

0 commit comments

Comments
 (0)