diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-27 11:25:05 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-27 11:25:05 +0200 |
| commit | ec136666d9592394a7fc3102a4f1007f9917005b (patch) | |
| tree | 5460240ef205afdfbc5ed1611993c9a584627e4a /internal/askcli/task_selector.go | |
| parent | 6fa6848496abd984156167a1c873fca6c724a1f7 (diff) | |
Move selector helpers into task selector
Diffstat (limited to 'internal/askcli/task_selector.go')
| -rw-r--r-- | internal/askcli/task_selector.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/askcli/task_selector.go b/internal/askcli/task_selector.go index ccae234..220aa7c 100644 --- a/internal/askcli/task_selector.go +++ b/internal/askcli/task_selector.go @@ -117,3 +117,38 @@ func looksLikeTaskAlias(selector string) bool { _, ok := decodeTaskAliasID(selector) return ok && !strings.Contains(selector, "-") } + +func displayResolvedTaskID(resolved resolvedTaskSelector) string { + return displayTaskAlias(resolved.UUID, map[string]string{resolved.UUID: resolved.Alias}) +} + +func displayTaskAlias(uuid string, aliases map[string]string) string { + if alias := strings.TrimSpace(aliases[uuid]); alias != "" { + return alias + } + return uuid +} + +// NormalizeUUID strips any leading "uuid:" prefix so callers can accept +// both "uuid:<value>" and bare UUID strings interchangeably. The returned +// value is always a plain UUID ready to be prefixed again when building +// taskwarrior filter arguments. +func NormalizeUUID(s string) string { + return strings.TrimPrefix(s, "uuid:") +} + +func IsNumericID(s string) bool { + if s == "" { + return false + } + for _, c := range s { + if c < '0' || c > '9' { + return false + } + } + return true +} + +func RejectNumericID() string { + return "error: use a task alias ID or UUID, not a numeric Taskwarrior task ID\n" +} |
