feat: add calendar update shortcut#678
Conversation
Change-Id: Ie2d4bde6cd28bbf4d7946db38c5c9be13edc6ba9
|
|
📝 WalkthroughWalkthroughA new Changes
Sequence DiagramsequenceDiagram
actor User
participant CLI as CLI Client
participant API as Lark API
participant Response as Result Formatter
User->>CLI: calendar +update --event-id=... --summary=... <br/> --add-attendee-ids=... --remove-attendee-ids=...
CLI->>CLI: Validate flags & constraints
rect rgba(100, 150, 255, 0.5)
Note over CLI,API: Sequential Execution Flow
CLI->>API: PATCH /events/{event_id}<br/>(summary, description, time, rrule,<br/>need_notification)
API-->>CLI: Event updated
CLI->>API: POST /events/{event_id}/<br/>attendees_batch_delete<br/>(user IDs, resource IDs)
API-->>CLI: Attendees removed
CLI->>API: POST /events/{event_id}/<br/>attendees<br/>(user, chat, resource entries)
API-->>CLI: Attendees added
end
CLI->>Response: Format result table<br/>(event_id, counts,<br/>summary/description/times)
Response-->>User: Display formatted output
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #678 +/- ##
==========================================
+ Coverage 62.96% 63.04% +0.08%
==========================================
Files 436 437 +1
Lines 38605 38847 +242
==========================================
+ Hits 24307 24491 +184
- Misses 12150 12184 +34
- Partials 2148 2172 +24 ☔ 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@44f84a8aecf1eb624dd29258840c8cd898fbf62c🧩 Skill updatenpx skills add larksuite/cli#feat/calendar-update-shortcut -y -g |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
shortcuts/calendar/calendar_update.go (1)
98-104: Use trimmed comparisons here for consistency with the rest of the file.
hasCalendarUpdateOperationuses rawlen(...) > 0, while the rest of the file (parseCalendarAttendeeIDs, the dry-run, and the executor) all guard withstrings.TrimSpace(...) != "". A whitespace-only flag (e.g.--add-attendee-ids " ") would currently pass the "nothing to update" validation but result in zero API calls during execute, returning success with no actions taken.♻️ Proposed fix
func hasCalendarUpdateOperation(runtime *common.RuntimeContext) bool { - if len(runtime.Str("add-attendee-ids")) > 0 || len(runtime.Str("remove-attendee-ids")) > 0 { + if strings.TrimSpace(runtime.Str("add-attendee-ids")) != "" || + strings.TrimSpace(runtime.Str("remove-attendee-ids")) != "" { return true } body, hasEventFields, err := buildCalendarUpdateEventData(runtime) return err == nil && hasEventFields && len(body) > 0 }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@shortcuts/calendar/calendar_update.go` around lines 98 - 104, hasCalendarUpdateOperation currently uses raw len(...) > 0 checks which let whitespace-only flags slip through; update it to mirror the rest of the file by trimming values before comparing. Specifically, replace len(runtime.Str("add-attendee-ids")) > 0 and len(runtime.Str("remove-attendee-ids")) > 0 with strings.TrimSpace(runtime.Str("add-attendee-ids")) != "" and strings.TrimSpace(runtime.Str("remove-attendee-ids")) != "", and change the body check from len(body) > 0 to strings.TrimSpace(body) != ""; keep the rest of the logic (err == nil && hasEventFields) the same so hasCalendarUpdateOperation returns true only for non-whitespace inputs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@shortcuts/calendar/calendar_update.go`:
- Around line 98-104: hasCalendarUpdateOperation currently uses raw len(...) > 0
checks which let whitespace-only flags slip through; update it to mirror the
rest of the file by trimming values before comparing. Specifically, replace
len(runtime.Str("add-attendee-ids")) > 0 and
len(runtime.Str("remove-attendee-ids")) > 0 with
strings.TrimSpace(runtime.Str("add-attendee-ids")) != "" and
strings.TrimSpace(runtime.Str("remove-attendee-ids")) != "", and change the body
check from len(body) > 0 to strings.TrimSpace(body) != ""; keep the rest of the
logic (err == nil && hasEventFields) the same so hasCalendarUpdateOperation
returns true only for non-whitespace inputs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a2063d6a-fc63-49c6-a75b-50a16a22b2e0
📒 Files selected for processing (8)
shortcuts/calendar/calendar_test.goshortcuts/calendar/calendar_update.goshortcuts/calendar/shortcuts.goskills/lark-calendar/SKILL.mdskills/lark-calendar/references/lark-calendar-schedule-meeting.mdskills/lark-calendar/references/lark-calendar-update.mdtests/cli_e2e/calendar/calendar_update_dryrun_test.gotests/cli_e2e/calendar/calendar_update_event_test.go
Summary
Add a
calendar +updateshortcut for updating existing calendar events and incrementally adding or removing attendees, chats, and meeting rooms.Changes
calendar +updatewith event field patching, attendee batch delete, attendee add, dry-run output, validation, and structured API errors.+update.Test Plan
make unit-testgo vet ./...gofmt -l .go mod tidyproduced nogo.mod/go.sumdiffgo run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/maingo test -race -gcflags="all=-N -l" -count=1 ./shortcuts/calendarRelated Issues
Summary by CodeRabbit
Release Notes
New Features
calendar +updatecommand to modify existing events: update event details (summary, description, start/end times, recurrence rules), incrementally add or remove attendees/rooms, and control attendee notifications. Includes dry-run preview mode.Documentation