Skip to content

Commit 2a800f8

Browse files
authored
Feature: 添加按插件类型的搜索过滤器 (#174)
* ✨ add plugin type search filter * 📝 update documentation about new search filter
1 parent 0ccc81f commit 2a800f8

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

nb_cli/cli/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def __call__(self, x: Adapter | Plugin | Driver, *, value: str) -> bool: ...
5555
(v.lower() in (t.label.lower() for t in x.tags))
5656
for v in value.strip().split(",")
5757
),
58+
"type:": lambda x, *, value: not value.strip()
59+
or not isinstance(x, Plugin)
60+
or value.strip() in "unknown"
61+
or (x.type is not None and value.strip() in x.type),
5862
}
5963

6064

nb_cli/config/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Plugin(PackageInfo):
5151
author: str
5252
homepage: str
5353
tags: list[Tag]
54+
type: str | None = None
5455
is_official: bool | None = None
5556
valid: bool | None = None
5657
skip_test: bool = False

website/docs/guide/advanced-search.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ NB-CLI 提供了一套高级搜索的支持,便于用户检索商店内容。
4141
- `#passing`:仅显示通过校验的插件
4242
- `#tag:标签名`:按标签筛选(逗号分隔多个标签)
4343
- `#author:作者名`:按作者筛选(逗号分隔多个作者)
44+
- `#type:插件类型`:按插件类型筛选(`application``library``unknown`
4445

4546
示例:
4647

@@ -55,6 +56,8 @@ NB-CLI 提供了一套高级搜索的支持,便于用户检索商店内容。
5556
- `!official`:排除官方项目
5657
- `!tag:xxx`:排除指定标签
5758
- `!author:xxx`:排除指定作者
59+
- `!passing`:排除通过校验的插件
60+
- `!type:xxx`:排除指定类型的插件
5861

5962
示例:
6063

@@ -67,7 +70,7 @@ NB-CLI 提供了一套高级搜索的支持,便于用户检索商店内容。
6770
可将关键词、`-` 前缀、`#`/`!` 前缀、带参数 filter 混合使用,支持分号分隔多组条件:
6871

6972
```
70-
工具 -测试 #official !tag:娱乐; 管理 #tag:管理
73+
工具 -测试 #official !tag:游戏; 管理 #tag:管理
7174
```
7275

7376
### 交互行为说明
@@ -76,3 +79,4 @@ NB-CLI 提供了一套高级搜索的支持,便于用户检索商店内容。
7679
- `!filter`:排除 filter 作用范围内的项目
7780
- `#filter`:仅保留 filter 作用范围内的项目
7881
- `tag:``author:` 可用逗号分隔多个值
82+
- `type:` 支持部分匹配,如 `app` 匹配 `application``lib` 匹配 `library`

0 commit comments

Comments
 (0)