feat: add task +get shortcut for single task detail retrieval#940
feat: add task +get shortcut for single task detail retrieval#940Zhang-986 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughA new ChangesGetTask Shortcut Feature
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/task/task_get.go`:
- Around line 31-34: The code is using extractTaskGuid(runtime.Str("task-id"))
without validating that the result is a real GUID, so applink URLs lacking a
guid query can be passed as the taskId; add a guard before PathEscape/GET: call
extractTaskGuid into a local (e.g., raw := runtime.Str("task-id"); guid :=
extractTaskGuid(raw)), then validate guid (e.g., ensure it differs from the raw
URL or matches the expected GUID pattern and does not contain URL characters
like "http", "/", or "?"); if validation fails, return a clear validation error
instead of building the API request that uses taskId; update the same logic for
the other occurrence referenced (lines 38-43) so both places validate before
calling common.NewDryRunAPI().GET(...) with taskId.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e7bbfee1-2f92-49b9-abfe-a0341277c429
📒 Files selected for processing (4)
shortcuts/task/shortcuts.goshortcuts/task/task_get.goshortcuts/task/task_get_test.gotests/cli_e2e/task/task_get_dryrun_test.go
There was a problem hiding this comment.
Pull request overview
This PR adds a missing “fetch single task by ID” capability to the task shortcuts by exposing the existing internal getTaskDetail helper as a standalone task +get shortcut, along with unit and E2E dry-run coverage.
Changes:
- Added new
task +getshortcut supporting--task-id(GUID or applink URL) with formatted output. - Registered
GetTaskin the task shortcut registry. - Added unit tests for pretty/json output and an E2E dry-run test covering GUID + applink URL parsing.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/cli_e2e/task/task_get_dryrun_test.go | Adds dry-run E2E coverage for task +get request shape and applink GUID extraction. |
| shortcuts/task/task_get.go | Implements the new GetTask shortcut (dry-run + execute output formatting). |
| shortcuts/task/task_get_test.go | Adds unit tests validating pretty and JSON output for the new shortcut. |
| shortcuts/task/shortcuts.go | Registers GetTask in Shortcuts() so the command becomes available. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
感谢你的贡献,也欢迎继续给 larksuite/cli 提 PR。 |
Summary
task 模块有 create、update、complete、search 这些命令,但唯独没有按 ID 查单个任务详情的功能。
getTaskDetail这个 helper 其实已经在+complete和+search里用了,只是没暴露成独立命令。这个 PR 就是把它补上。The task module has shortcuts for creating, updating, completing, and searching tasks, but no way to fetch a single task by ID. The
getTaskDetailhelper already exists internally (used by+completeand+search), so this PR just exposes it as a standalonetask +getcommand.Changes
新增
task +get命令,支持--task-id(GUID 或 applink URL)、--format、--jq、--dry-run在
Shortcuts()里注册GetTask补了单元测试(pretty/json 输出)和 dry-run E2E 测试(GUID 输入 + applink URL 解析)
Added
task +getshortcut with--task-id(GUID or applink URL),--format,--jq,--dry-runRegistered
GetTaskinShortcuts()Added unit tests (pretty/json output) and dry-run E2E test (GUID input + applink URL resolution)
Test Plan
go test ./shortcuts/task/... -race通过go vet/gofmt/go mod tidy/golangci-lint均无问题dry-run E2E 测试通过
单元测试覆盖 pretty 和 json 两种输出格式
本地
lark-cli task +get --task-id xxx验证命令正常工作go test ./shortcuts/task/... -racepassesgo vet/gofmt/go mod tidy/golangci-lintall cleanDry-run E2E test passes
Unit tests cover both pretty and json output formats
Manual
lark-cli task +get --task-id xxxverificationRelated Issues
Summary by CodeRabbit
task +getshortcut to retrieve and display individual task details by ID, including summary, description, creation and due dates, status, and URL.