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 | |
| parent | 6fa6848496abd984156167a1c873fca6c724a1f7 (diff) | |
Move selector helpers into task selector
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/askcli/formatter.go | 35 | ||||
| -rw-r--r-- | internal/askcli/task_selector.go | 35 |
2 files changed, 35 insertions, 35 deletions
diff --git a/internal/askcli/formatter.go b/internal/askcli/formatter.go index 0e7edfc..9dfaf4a 100644 --- a/internal/askcli/formatter.go +++ b/internal/askcli/formatter.go @@ -171,17 +171,6 @@ func FormatError(err error, taskID string) string { return fmt.Sprintf("error: %v\n", err) } -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 -} - func formatTaskDependencies(depends []string, aliases map[string]string) string { items := make([]string, 0, len(depends)) for _, uuid := range depends { @@ -198,27 +187,3 @@ func formatTaskReference(uuid string, aliases map[string]string) string { } return fmt.Sprintf("%s (%s)", alias, 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" -} 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" +} |
