Add label create, update, and delete operations#59
Open
wesnick wants to merge 1 commit into
Open
Conversation
gwcli previously only listed/applied/removed labels; creation and deletion required the Gmail UI. Add imperative label CRUD via the Gmail users.labels API: - labels create <name> — create a user label (rejects duplicates), with --message-list-visibility / --label-list-visibility flags and '/'-nested names - labels update <label> — rename and/or change visibility - labels delete <label> — delete a user label (--force required, refuses system labels) create/update/delete accept a label name or ID via the shared resolveLabelID helper, and any mutation invalidates the connection's label cache. The gmail.labels OAuth scope already requested covers all of this. Also fix two pre-existing dispatch bugs where "labels apply" and "labels remove" never matched because Kong includes the <label-id> arg placeholder in the command string. Initialize the label/message caches in NewFake so LoadLabels works under test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UdqRpUFcLqZQjFpDDkbnxk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements full CRUD operations for Gmail labels via the
gwcli labelscommand group. Users can now create, update (rename/change visibility), and delete labels in addition to the existing list/apply/remove operations.Changes
New command handlers (
labels.go):runLabelsCreate()- Create a new user label with optional visibility settingsrunLabelsUpdate()- Rename a label or change its message/label list visibilityrunLabelsDelete()- Permanently delete a user label (requires--forceflag)New connection methods (
pkg/gwcli/connection.go):CreateLabel()- Callsgmail.Users.Labels.CreateAPIUpdateLabel()- Callsgmail.Users.Labels.PatchAPIDeleteLabel()- Callsgmail.Users.Labels.DeleteAPIinvalidateLabels()- Clears label cache after mutations so subsequent operations reload from APImessageCacheandlabelCacheinNewFake()for testingCLI command definitions (
main.go):labels create <name>- Create label with optional--message-list-visibilityand--label-list-visibilityflagslabels update <label-id>- Update label by name or ID with optional--name,--message-list-visibility,--label-list-visibilityflagslabels delete <label-id>- Delete label by name or ID, requires--forceflagComprehensive test suite (
labels_test.go):TestRunLabelsCreate- Verify label creation with JSON outputTestRunLabelsCreateEmptyName- Reject empty label namesTestRunLabelsCreateDuplicate- Reject duplicate names (case-insensitive)TestRunLabelsUpdate- Verify label rename with name resolutionTestRunLabelsUpdateNoChanges- Reject updates with no fields providedTestRunLabelsDelete- Verify label deletion with JSON outputTestRunLabelsDeleteRequiresForce- Require--forceflagTestRunLabelsDeleteSystemLabel- Prevent deletion of system labels (INBOX, SENT, etc.)Documentation (
CLAUDE.md):Implementation Details
createchecks existing labels case-insensitively before creatingdeleteprevents removal of Gmail system labels (type="system") with a clear error messageupdateanddeleteaccept label name or ID, resolved via the sharedresolveLabelID()helperinvalidateLabels()to ensure subsequent operations see fresh data from the API--message-list-visibility:showorhide--label-list-visibility:labelShow,labelShowIfUnread, orlabelHide--json) and human-readable text outputdeleterequires explicit--forceflag (non-interactive rule Refactor app into single root command #3 from CLAUDE.md)https://claude.ai/code/session_01UdqRpUFcLqZQjFpDDkbnxk