Skip to content

Commit 37e948c

Browse files
cailmdaleyclaude
andcommitted
Split comma-separated tags in tag/add commands
"felt tag id claim,tapestry:foo" now correctly adds two separate tags instead of one tag containing the comma. Applies to tag, untag, and add -t. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 636fab9 commit 37e948c

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

cmd/add.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ var addCmd = &cobra.Command{
5858
f.Status = addStatus
5959
}
6060
if len(addTags) > 0 {
61-
for _, tag := range addTags {
62-
f.AddTag(tag)
61+
for _, raw := range addTags {
62+
for _, tag := range splitTags(raw) {
63+
f.AddTag(tag)
64+
}
6365
}
6466
}
6567
if len(addDeps) > 0 {

cmd/tag.go

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"fmt"
5+
"strings"
56

67
"github.com/cailmdaley/felt/internal/felt"
78
"github.com/spf13/cobra"
@@ -24,17 +25,19 @@ var tagCmd = &cobra.Command{
2425
return err
2526
}
2627

27-
tag := args[1]
28-
if f.HasTag(tag) {
29-
return fmt.Errorf("felt %s already has tag %q", f.ID, tag)
28+
// Split comma-separated tags: "claim, tapestry:foo" → ["claim", "tapestry:foo"]
29+
tags := splitTags(args[1])
30+
for _, tag := range tags {
31+
if f.HasTag(tag) {
32+
continue
33+
}
34+
f.AddTag(tag)
35+
fmt.Printf("%s +[%s]\n", f.ID, tag)
3036
}
3137

32-
f.AddTag(tag)
3338
if err := storage.Write(f); err != nil {
3439
return err
3540
}
36-
37-
fmt.Printf("%s +[%s]\n", f.ID, tag)
3841
return nil
3942
},
4043
}
@@ -56,21 +59,36 @@ var untagCmd = &cobra.Command{
5659
return err
5760
}
5861

59-
tag := args[1]
60-
if !f.HasTag(tag) {
61-
return fmt.Errorf("felt %s does not have tag %q", f.ID, tag)
62+
tags := splitTags(args[1])
63+
for _, tag := range tags {
64+
if !f.HasTag(tag) {
65+
continue
66+
}
67+
f.RemoveTag(tag)
68+
fmt.Printf("%s -[%s]\n", f.ID, tag)
6269
}
6370

64-
f.RemoveTag(tag)
6571
if err := storage.Write(f); err != nil {
6672
return err
6773
}
68-
69-
fmt.Printf("%s -[%s]\n", f.ID, tag)
7074
return nil
7175
},
7276
}
7377

78+
// splitTags splits comma-separated tag input into individual tags.
79+
// "claim, tapestry:foo" → ["claim", "tapestry:foo"]
80+
func splitTags(input string) []string {
81+
parts := strings.Split(input, ",")
82+
var tags []string
83+
for _, p := range parts {
84+
p = strings.TrimSpace(p)
85+
if p != "" {
86+
tags = append(tags, p)
87+
}
88+
}
89+
return tags
90+
}
91+
7492
func init() {
7593
rootCmd.AddCommand(tagCmd)
7694
rootCmd.AddCommand(untagCmd)

0 commit comments

Comments
 (0)