fix: reject positional arguments in shortcuts#227
Conversation
Shortcuts silently ignored positional arguments (e.g. `lark-cli docs +search "hello"`), causing empty results. Add Args validator to all declarative shortcuts so cobra prints usage and a clear error message telling users to pass values via flags instead. Change-Id: I7579f9c871138cf91dd5f5d8c1d51bda3f77a1db Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdded a positional-argument validator and wired it into Cobra command construction so subcommands reject positional args; includes unit tests covering single, multiple, and empty/nil argument cases. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR fixes silent swallowing of positional arguments in declarative shortcut commands by wiring a Key changes:
Confidence Score: 5/5Safe to merge — the change is minimal, well-tested, and all prior review concerns have been addressed. No P0 or P1 findings remain. All three issues flagged in the previous review round (unused parameter, first-arg-only error message, missing multi-arg test) are fully resolved in this revision. The implementation is correct, the test coverage is solid, and the change has a very small blast radius (only declarative shortcut commands). No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["User runs: lark-cli docs +search hello"] --> B["cobra parses command"]
B --> C{"Args validator\nrejectPositionalArgs()"}
C -- "len(args) == 0" --> D["RunE: runShortcut()"]
C -- "len(args) > 0" --> E["Return plain error\npositional arguments are not supported"]
E --> F["cobra prints Usage + Error line\nno JSON envelope"]
D --> G["API call succeeds"]
Reviews (2): Last reviewed commit: "fix: address PR review comments" | Re-trigger Greptile |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@1b6d962a43deb5741654ad4ef2c0aa1f6588a282🧩 Skill updatenpx skills add larksuite/cli#fix/reject-positional-args -y -g |
- Remove unused *Shortcut parameter from rejectPositionalArgs - Show all positional args in error message instead of only the first - Add test case for multiple positional arguments Change-Id: Ifea92d09ddabcd35fbf2db98d9888d18af59b894 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
lark-cli docs +search "hello"),导致空搜索结果Args校验器,传入位置参数时打印 usage 并报错:positional arguments are not supported (got "hello"); pass values via flagsTest plan
go test ./shortcuts/common/... -run TestRejectPositionalArgs通过go test ./shortcuts/common/...全量通过go build ./...编译通过lark-cli docs +search "hello"输出 usage + 错误提示lark-cli docs +search --query "hello"正常工作🤖 Generated with Claude Code
Summary by CodeRabbit