feat: add --json flag as no-op alias for --format json#1104
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a conditional ChangesJSON flag shorthand
sequenceDiagram
participant User
participant CLI
participant registerShortcutFlagsWithContext
participant APICommand
participant ServiceMethodCommand
participant Tests
User->>CLI: run command with `--json`
CLI->>registerShortcutFlagsWithContext: mount shortcut (register `--json` if enabled)
registerShortcutFlagsWithContext->>APICommand: add `--json` flag when no conflict
registerShortcutFlagsWithContext->>ServiceMethodCommand: add `--json` flag when no conflict
APICommand->>Tests: parsed opts accept `--json`
ServiceMethodCommand->>Tests: run callback receives options
🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Suggested labels
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 |
68c5eee to
9729b11
Compare
|
Actionable comments posted: 0 |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@d0cb4bfa17d21e93abb74b4937b029f9d462f8db🧩 Skill updatenpx skills add MaxHuang22/cli#feat/secret-medallion -y -g |
9729b11 to
882be9d
Compare
|
Actionable comments posted: 0 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1104 +/- ##
=======================================
Coverage 69.21% 69.22%
=======================================
Files 634 634
Lines 59553 59557 +4
=======================================
+ Hits 41222 41228 +6
+ Misses 15012 15011 -1
+ Partials 3319 3318 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
882be9d to
5fc2d9f
Compare
Skip registration when a custom --json flag already exists on the command (e.g. base shortcuts use --json for body input). Change-Id: If66236cadeea7fa81811061cce775deff51b92ce
5fc2d9f to
d0cb4bf
Compare
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/common/runner_flag_completion_test.go`:
- Around line 150-170: The test
TestShortcutMount_JsonFlag_RegisteredWithoutHasFormat is asserting the opposite
of the shortcut contract: when Shortcut.HasFormat is false the test should
assert that neither the "json" nor the "format" flags are registered after
calling shortcut.Mount(parent, f). Update the assertions to expect
cmd.Flags().Lookup("json") == nil (and similarly for "format") and fail if
either flag is present, so the test verifies that no output-format flags are
added for shortcuts with HasFormat == false.
🪄 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: 6aa9f271-4791-4b72-82f4-897605d190b5
📒 Files selected for processing (6)
cmd/api/api.gocmd/api/api_test.gocmd/service/service.gocmd/service/service_test.goshortcuts/common/runner.goshortcuts/common/runner_flag_completion_test.go
🚧 Files skipped from review as they are similar to previous changes (4)
- cmd/service/service_test.go
- cmd/api/api.go
- shortcuts/common/runner.go
- cmd/service/service.go
* feat(api): add --json flag as no-op alias for --format json * feat(service): add --json flag as no-op alias for --format json * feat(shortcut): add --json flag as no-op alias for --format json Skip registration when a custom --json flag already exists on the command (e.g. base shortcuts use --json for body input). Change-Id: If66236cadeea7fa81811061cce775deff51b92ce
Summary
AI agents frequently pass
--jsonwhen calling lark-cli commands, causing "unknown flag" errors. This adds--jsonas a no-op bool flag to api, service, and shortcut (HasFormat) commands so the flag is silently accepted. Since--formatalready defaults tojson, no behavioral wiring is needed.Changes
cmd.Flags().Bool("json", ...)tocmd/api/api.goafter--formatregistrationcmd.Flags().Bool("json", ...)tocmd/service/service.goafter--formatregistrationcmd.Flags().Bool("json", ...)toshortcuts/common/runner.goinsideHasFormatblock, with aLookup("json")guard to skip registration when a custom--jsonflag already exists (e.g. base domain shortcuts use--jsonfor body input)Test Plan
make unit-testpassedlark-cli api GET /open-apis/test --json --dry-runaccepted without error;lark-cli calendar +agenda --json --helpshows--jsonflagRelated Issues
N/A
Summary by CodeRabbit
New Features
Tests