feat: unconditionally inject --format flag for all shortcuts#1156
feat: unconditionally inject --format flag for all shortcuts#1156MaxHuang22 wants to merge 3 commits into
Conversation
Removes three HasFormat guards in runner.go so every shortcut gets --format regardless of the Shortcut.HasFormat field value. Shortcuts that already define a custom 'format' flag in Flags[] are skipped to avoid redefinition panics (e.g. mail +triage, +watch). HasFormat is retained in the struct but marked deprecated. Change-Id: I5e8fe07e839d5aed4cefaf7d753dabbaee68fb6e
|
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 (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThe shortcut framework now always injects and reads the ChangesUniversal Format Flag
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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 docstrings
🧪 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/common/runner_format_universal_test.go`:
- Around line 17-18: Add environment isolation by calling
t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) at the start of the test
before interacting with cmdutil.TestFactory; specifically, insert t.Setenv(...)
prior to the line calling cmdutil.TestFactory(t, nil) (the t variable in the
test) so the test uses an isolated config dir instead of shared state.
🪄 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: 274a54cb-8903-47be-b699-c8737cfbd0d6
📒 Files selected for processing (3)
shortcuts/common/runner.goshortcuts/common/runner_format_universal_test.goshortcuts/common/types.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1156 +/- ##
==========================================
+ Coverage 68.63% 68.74% +0.11%
==========================================
Files 625 627 +2
Lines 58386 58577 +191
==========================================
+ Hits 40071 40267 +196
+ Misses 15027 15018 -9
- Partials 3288 3292 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@7e947222cd0e4648e2e1f4026718cec024659226🧩 Skill updatenpx skills add larksuite/cli#feat/shortcut-format-universal -y -g |
Change-Id: I3a59942aa8a6753cd949ca42f2a19a72f032ff55
|
Actionable comments posted: 0 |
Change-Id: I0146e5a2f57f5419863bdeeaa1a662fd8f70bddf
|
Actionable comments posted: 0 |
Summary
--formatflag was only injected for shortcuts that explicitly setHasFormat: true, leaving ~190 shortcuts without output format control. This PR removes the threeHasFormatguards inrunner.goso every shortcut gets--formatunconditionally. Shortcuts that already define a customformatflag inFlags[](e.g.mail +triage,mail +watch) are skipped viaLookup("format") == nilto avoid redefinition panics.HasFormatis retained in the struct but marked deprecated.Changes
shortcuts/common/runner.go: remove threeif s.HasFormatguards; addcmd.Flags().Lookup("format") == nilcheck before auto-injection to skip shortcuts with custom format flagsshortcuts/common/types.go: markHasFormatfield asDeprecated:shortcuts/common/runner_format_universal_test.go(new): verifyHasFormat: falseshortcut still receives--formatafter mountTest Plan
make unit-testpassedlark-cli calendar +rsvp --help—--formatnow present;lark-cli calendar +agenda --format table --dry-run— no regressionRelated Issues
N/A
Summary by CodeRabbit
New Features
--formatflag is now universally available for all shortcuts, defaulting to "json" for consistent output.Tests
--formatflag is always registered regardless of shortcut configuration.Documentation