beads/internal/utils/strings.go
beads/crew/emma cee7dcacd9 fix: complete decision type aliases and help strings
Add dec/adr aliases to utils.NormalizeIssueType() so CLI commands
like `bd list --type dec` resolve correctly. Add TypeDecision to
coreWorkTypes so `bd types` lists it. Update remaining help strings
in export, ready, and claude-plugin commands. Add alias test cases.

Co-authored-by: dariye <dariye@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-11 17:23:21 -08:00

42 lines
1 KiB
Go

package utils
import "strings"
// issueTypeAliases maps shorthand type names to canonical types
var issueTypeAliases = map[string]string{
"mr": "merge-request",
"feat": "feature",
"mol": "molecule",
"enhancement": "feature",
"dec": "decision",
"adr": "decision",
}
// NormalizeIssueType expands type aliases to their canonical forms.
// For example: "mr" -> "merge-request", "feat" -> "feature", "mol" -> "molecule"
// Returns the input unchanged if it's not an alias.
func NormalizeIssueType(t string) string {
if canonical, ok := issueTypeAliases[strings.ToLower(t)]; ok {
return canonical
}
return t
}
// NormalizeLabels trims whitespace, removes empty strings, and deduplicates labels
// while preserving order.
func NormalizeLabels(ss []string) []string {
seen := make(map[string]struct{})
out := make([]string, 0, len(ss))
for _, s := range ss {
s = strings.TrimSpace(s)
if s == "" {
continue
}
if _, ok := seen[s]; ok {
continue
}
seen[s] = struct{}{}
out = append(out, s)
}
return out
}