feat: add --add-labels and --remove-labels flags#44
Open
michael-ford wants to merge 1 commit intojoa23:mainfrom
Open
feat: add --add-labels and --remove-labels flags#44michael-ford wants to merge 1 commit intojoa23:mainfrom
michael-ford wants to merge 1 commit intojoa23:mainfrom
Conversation
The existing --labels flag uses replace semantics, sending a full labelIds array to the Linear API and wiping any existing labels. This is problematic for workflows that need to incrementally add or remove labels without affecting the rest. New flags: - --add-labels: adds labels to the issue without removing existing ones - --remove-labels: removes specific labels without affecting others Both can be used together in a single command. They are mutually exclusive with --labels (which remains as the replace-all mode). Implementation: - CLI layer: new flags with mutual exclusivity validation - Service layer: fetch current labels from issue, resolve names to IDs, merge/subtract using a set, then send combined labelIds - No new GraphQL queries needed: GetIssue already returns labels
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
The existing
--labelsflag onissues updateuses replace semantics -- it sends a fulllabelIdsarray to the Linear API, wiping any existing labels on the issue. This makes it difficult to incrementally manage labels without knowing and re-specifying all current labels.This PR adds two new flags:
--add-labels-- adds the specified labels without removing existing ones--remove-labels-- removes the specified labels without affecting othersBoth flags can be used together in a single command. They are mutually exclusive with
--labels(which remains as the replace-all mode).How it works
Since the Linear API's
labelIdsfield is always a full replacement, the implementation:GetIssuequery (which already returnslabels { nodes { id name } })ResolveLabelIdentifiermethod--add-labels) or subtracts (for--remove-labels) using a setlabelIdsin the update mutationNo new GraphQL queries or API calls are needed beyond what already exists.
Usage examples
Files changed
internal/cli/issues.go-- new flag definitions, mutual exclusivity validation, updated help text and examplesinternal/service/issue.go--AddLabelIDs/RemoveLabelIDsfields onUpdateIssueInput, merge/subtract logic,extractCurrentLabelIDshelperTest plan
go build -o linear ./cmd/linear/go test ./...(396 tests)--add-labelsand--remove-labelsappear inlinear issues update --help--labelswith--add-labelsreturns an error--labelswith--remove-labelsreturns an error--add-labels "newlabel"adds the label without removing existing labels--remove-labels "oldlabel"removes only the specified label--add-labels "a" --remove-labels "b"works together in one command--labels "a,b"still works as replace-all (existing behavior preserved)