-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(mail): support triage filter shorthand #2025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ lark-cli mail +triage | |
|
|
||
| # 查看收件箱未读 | ||
| lark-cli mail +triage --filter '{"folder":"inbox","is_unread":true}' | ||
| lark-cli mail +triage --folder=INBOX --filter=is_unread | ||
|
|
||
| # 全文搜索 | ||
| lark-cli mail +triage --query "合同审批" | ||
|
|
@@ -25,6 +26,7 @@ lark-cli mail +triage --query "项目评审" --filter '{"time_range":{"start_tim | |
|
|
||
| # 指定文件夹 | ||
| lark-cli mail +triage --filter '{"folder":"sent"}' | ||
| lark-cli mail +triage --filter folder_id=DRAFT | ||
|
|
||
| # 系统标签(可通过 folder 或 label 传入,搜索时自动转为 folder) | ||
| lark-cli mail +triage --filter '{"folder":"flagged"}' | ||
|
|
@@ -47,7 +49,8 @@ lark-cli mail +triage --page-size 10 | |
|
|
||
| | 参数 | 默认 | 说明 | | ||
| |------|------|------| | ||
| | `--filter <json>` | — | 筛选条件(见下方字段说明) | | ||
| | `--filter <json|shorthand>` | — | 筛选条件(见下方字段说明)。支持 JSON,也支持 `folder_id=DRAFT`、`folder=INBOX`、`is_unread`/`unread`、`is_read`/`read` | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Escape the pipe in the table cell.
🧰 Tools🪛 markdownlint-cli2 (0.23.0)[warning] 52-52: Table column count (MD056, table-column-count) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
| | `--folder <folder>` | — | 文件夹名称或 ID 的拆分写法,会归并为 filter folder;可与 `--filter=is_unread` 搭配,不能与 `--filter` 中的 `folder`/`folder_id` 同时使用 | | ||
| | `--query <text>` | — | 全文搜索关键词 | | ||
| | `--format <mode>` | `table` | `table` / `json` / `data`(`json` 和 `data` 均输出含分页信息的对象) | | ||
| | `--max <n>` | `20` | 最大返回条数(1-400),内部自动分页拉取 | | ||
|
|
@@ -73,7 +76,7 @@ lark-cli mail +triage --page-size 10 | |
|
|
||
| > **系统标签说明**:`IMPORTANT`/`FLAGGED`/`OTHER` 可通过 `folder` 或 `label` 传入(也支持中文别名 `重要邮件`/`已加旗标`/`其他邮件`、搜索名 `priority`/`flagged`/`other`)。搜索时自动转为 folder 字段,列表时自动转为 label_id。label list 接口不返回这三个系统标签。 | ||
| > | ||
| > **⚠️ 注意**:查询未读请用 `"is_unread":true`。 | ||
| > **简写说明**:常用筛选可直接写 `--filter folder_id=DRAFT`、`--filter=folder=INBOX`、`--filter=is_unread`、`--filter=is_read`。`is_read` 会转换为 `is_unread=false` 并走 search 路径,避免 list API 忽略已读过滤。 | ||
| 可运行 `mail +triage --print-filter-schema` 查看完整字段说明。 | ||
|
|
||
| ## 输出 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: larksuite/cli
Length of output: 2547
🏁 Script executed:
Repository: larksuite/cli
Length of output: 50370
🏁 Script executed:
Repository: larksuite/cli
Length of output: 5803
🏁 Script executed:
Repository: larksuite/cli
Length of output: 312
🏁 Script executed:
Repository: larksuite/cli
Length of output: 230
🏁 Script executed:
Repository: larksuite/cli
Length of output: 230
🌐 Web query:
Go encoding/json Decoder Decode reads one JSON value and trailing characters invalid input💡 Result:
In Go, the encoding/json Decoder.Decode method is designed to read and parse a single JSON value from an input stream [1][2]. By design, it consumes only the bytes necessary to form that valid JSON value [1]. If the input stream contains additional data after the valid JSON value, the Decoder does not treat this as an error; the trailing characters remain in the underlying buffer or the io.Reader, effectively left for subsequent operations [3][4]. This behavior can often lead to confusion when developers assume Decode will validate that a stream contains exactly one JSON value [3]. Because the decoder may buffer more data than is required for the current value, those "leftover" bytes—including trailing whitespace or subsequent JSON objects—are not automatically discarded or validated [4]. If you need to ensure that no trailing data exists or to process multiple JSON values, you can use one of the following patterns: 1. Check for EOF: After calling Decode, verify that no meaningful data remains by calling the Decoder.Token method. If there is no more data, Token will return io.EOF [3][2]. Example: d:= json.NewDecoder(r) if err:= d.Decode(&v); err!= nil { return err } if _, err:= d.Token; err!= io.EOF { return fmt.Errorf("unexpected trailing data") } 2. Inspect the Buffer: You can use the Decoder.Buffered method to inspect any data that has been read from the io.Reader but not yet consumed by a Decode or Token call [2][4]. Note that this only returns the data currently held in the internal buffer, not the entire remainder of the io.Reader [4][5]. This design allows the Decoder to support streaming multiple JSON objects from a single source, which is a primary use case for the package [3]. If the input contains invalid JSON syntax after the first object, the decoder will only report an error if it attempts to parse that specific section as part of a subsequent value [1][6].
Citations:
Reject trailing and non-object JSON filters.
json.Decoder.Decodeonly reads one JSON value, so--filter '{"folder":"INBOX"} {"is_unread":true}'applies only the first object, and--filter nulldecodes as an emptytriageFilter. Require a single JSON object and EOF after decoding, returning a typed--filtervalidation error.🤖 Prompt for AI Agents
Source: Coding guidelines