summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-27 06:51:24 +0200
committerPaul Buetow <paul@buetow.org>2026-03-27 06:51:24 +0200
commitf19a4740992f3fd5f6d2f8b13850c9eb637f6a76 (patch)
tree5296cf52515636ebb43987fd87564ff2f99e6d2b /internal
parent426b836d03078a5e438319d0d2a90d9d2a93430b (diff)
fix ask alias output wording 7f53c2ff-4eb0-4c7e-bf90-f44587364f4a
Diffstat (limited to 'internal')
-rw-r--r--internal/askcli/command_delete.go2
-rw-r--r--internal/askcli/command_delete_test.go8
-rw-r--r--internal/askcli/command_dep.go4
-rw-r--r--internal/askcli/command_dep_test.go28
-rw-r--r--internal/askcli/command_info_add.go2
-rw-r--r--internal/askcli/command_info_add_test.go3
-rw-r--r--internal/askcli/command_write.go16
-rw-r--r--internal/askcli/command_write_test.go12
-rw-r--r--internal/askcli/formatter.go2
-rw-r--r--internal/askcli/formatter_test.go4
10 files changed, 62 insertions, 19 deletions
diff --git a/internal/askcli/command_delete.go b/internal/askcli/command_delete.go
index 24753d5..1efaad9 100644
--- a/internal/askcli/command_delete.go
+++ b/internal/askcli/command_delete.go
@@ -8,7 +8,7 @@ import (
func (d Dispatcher) handleDelete(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
if len(args) < 2 {
- io.WriteString(stderr, "error: ask delete requires a UUID argument\n")
+ io.WriteString(stderr, "error: ask delete requires an ID or UUID argument\n")
return 1, nil
}
resolved, _, code, err := d.resolveTaskSelector(ctx, args[1], stderr)
diff --git a/internal/askcli/command_delete_test.go b/internal/askcli/command_delete_test.go
index 7d049c6..6161d39 100644
--- a/internal/askcli/command_delete_test.go
+++ b/internal/askcli/command_delete_test.go
@@ -64,8 +64,8 @@ func TestHandleDelete_NumericID(t *testing.T) {
if err != nil {
t.Fatalf("delete returned unexpected error: %v", err)
}
- if !strings.Contains(stderr.String(), "use UUID") {
- t.Fatalf("stderr = %q, want 'use UUID' message", stderr.String())
+ if !strings.Contains(stderr.String(), "task alias ID or UUID") {
+ t.Fatalf("stderr = %q, want alias-or-UUID message", stderr.String())
}
}
@@ -82,8 +82,8 @@ func TestHandleDelete_MissingUUID(t *testing.T) {
if err != nil {
t.Fatalf("delete returned unexpected error: %v", err)
}
- if !strings.Contains(stderr.String(), "requires a UUID") {
- t.Fatalf("stderr = %q, want 'requires a UUID' message", stderr.String())
+ if !strings.Contains(stderr.String(), "requires an ID or UUID") {
+ t.Fatalf("stderr = %q, want 'requires an ID or UUID' message", stderr.String())
}
}
diff --git a/internal/askcli/command_dep.go b/internal/askcli/command_dep.go
index 0508b39..adfb232 100644
--- a/internal/askcli/command_dep.go
+++ b/internal/askcli/command_dep.go
@@ -27,7 +27,7 @@ func (d Dispatcher) handleDep(ctx context.Context, args []string, stdout, stderr
func (d Dispatcher) handleDepAddRm(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
if len(args) < 4 {
- io.WriteString(stderr, "error: ask dep add/rm requires <uuid> <dep-uuid>\n")
+ io.WriteString(stderr, "error: ask dep add/rm requires <id|uuid> <dep-id|dep-uuid>\n")
return 1, nil
}
resolved, _, code, err := d.resolveTaskSelector(ctx, args[2], stderr)
@@ -59,7 +59,7 @@ func (d Dispatcher) handleDepAddRm(ctx context.Context, args []string, stdout, s
func (d Dispatcher) handleDepList(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
if len(args) < 3 {
- io.WriteString(stderr, "error: ask dep list requires <uuid>\n")
+ io.WriteString(stderr, "error: ask dep list requires <id|uuid>\n")
return 1, nil
}
_, tasks, code, err := d.resolveTaskSelector(ctx, args[2], stderr)
diff --git a/internal/askcli/command_dep_test.go b/internal/askcli/command_dep_test.go
index f674d28..93e5175 100644
--- a/internal/askcli/command_dep_test.go
+++ b/internal/askcli/command_dep_test.go
@@ -123,6 +123,31 @@ func TestHandleDep_ListSuccess(t *testing.T) {
}
}
+func TestHandleDep_ListAssignsAliasForUnknownDependency(t *testing.T) {
+ now := useIsolatedTaskAliasCache(t)
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 1,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "uuid-1", Alias: "0", CreatedAt: now},
+ },
+ })
+
+ jsonData := `[{"uuid":"uuid-1","description":"Task","status":"pending","priority":"M","tags":[],"urgency":10,"depends":["dep-1"]}]`
+ d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
+ io.WriteString(stdout, jsonData)
+ return 0, nil
+ }})
+ var stdout, stderr bytes.Buffer
+ code, _ := d.Dispatch(context.Background(), []string{"dep", "list", "uuid-1"}, nil, &stdout, &stderr)
+ if code != 0 {
+ t.Fatalf("dep list code = %d, want 0", code)
+ }
+ if got := stdout.String(); got != "1\n" {
+ t.Fatalf("stdout = %q, want assigned alias", got)
+ }
+}
+
func TestHandleDep_UnknownOp(t *testing.T) {
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
return 0, nil
@@ -224,4 +249,7 @@ func TestHandleDep_NumericUUID(t *testing.T) {
if code != 1 {
t.Fatalf("dep add code = %d, want 1 for numeric UUID", code)
}
+ if !strings.Contains(stderr.String(), "task alias ID or UUID") {
+ t.Fatalf("stderr = %q, want alias-or-UUID guidance", stderr.String())
+ }
}
diff --git a/internal/askcli/command_info_add.go b/internal/askcli/command_info_add.go
index 4fa0941..1daacfb 100644
--- a/internal/askcli/command_info_add.go
+++ b/internal/askcli/command_info_add.go
@@ -54,7 +54,7 @@ func (d Dispatcher) startedInfoTasks(ctx context.Context, stderr io.Writer) ([]T
case 1:
return tasks, 0, nil
default:
- return nil, 1, fmt.Errorf("multiple started tasks found; pass a UUID explicitly")
+ return nil, 1, fmt.Errorf("multiple started tasks found; pass an ID or UUID explicitly")
}
}
diff --git a/internal/askcli/command_info_add_test.go b/internal/askcli/command_info_add_test.go
index 11bc451..9261a73 100644
--- a/internal/askcli/command_info_add_test.go
+++ b/internal/askcli/command_info_add_test.go
@@ -208,6 +208,9 @@ func TestHandleInfo_MissingUUID_MultipleStartedTasks(t *testing.T) {
if !strings.Contains(stderr.String(), "multiple started tasks found") {
t.Fatalf("stderr = %q, want multiple-started-tasks error", stderr.String())
}
+ if !strings.Contains(stderr.String(), "ID or UUID explicitly") {
+ t.Fatalf("stderr = %q, want ID-or-UUID guidance", stderr.String())
+ }
}
func TestHandleAdd_Success(t *testing.T) {
diff --git a/internal/askcli/command_write.go b/internal/askcli/command_write.go
index 643f74e..477e097 100644
--- a/internal/askcli/command_write.go
+++ b/internal/askcli/command_write.go
@@ -9,7 +9,7 @@ import (
func (d Dispatcher) handleDenotate(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
if len(args) < 3 {
- io.WriteString(stderr, "error: ask denotate requires a UUID and text argument\n")
+ io.WriteString(stderr, "error: ask denotate requires an ID or UUID and text argument\n")
return 1, nil
}
resolved, _, code, err := d.resolveTaskSelector(ctx, args[1], stderr)
@@ -29,7 +29,7 @@ func (d Dispatcher) handleDenotate(ctx context.Context, args []string, stdout, s
func (d Dispatcher) handleModify(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
if len(args) < 3 {
- io.WriteString(stderr, "error: ask modify requires a UUID and modification args\n")
+ io.WriteString(stderr, "error: ask modify requires an ID or UUID and modification args\n")
return 1, nil
}
resolved, _, code, err := d.resolveTaskSelector(ctx, args[1], stderr)
@@ -49,7 +49,7 @@ func (d Dispatcher) handleModify(ctx context.Context, args []string, stdout, std
func (d Dispatcher) handleAnnotate(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
if len(args) < 3 {
- io.WriteString(stderr, "error: ask annotate requires a UUID and note argument\n")
+ io.WriteString(stderr, "error: ask annotate requires an ID or UUID and note argument\n")
return 1, nil
}
resolved, _, code, err := d.resolveTaskSelector(ctx, args[1], stderr)
@@ -69,7 +69,7 @@ func (d Dispatcher) handleAnnotate(ctx context.Context, args []string, stdout, s
func (d Dispatcher) handleStart(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
if len(args) < 2 {
- io.WriteString(stderr, "error: ask start requires a UUID argument\n")
+ io.WriteString(stderr, "error: ask start requires an ID or UUID argument\n")
return 1, nil
}
resolved, _, code, err := d.resolveTaskSelector(ctx, args[1], stderr)
@@ -90,7 +90,7 @@ func (d Dispatcher) handleStart(ctx context.Context, args []string, stdout, stde
func (d Dispatcher) handleStop(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
if len(args) < 2 {
- io.WriteString(stderr, "error: ask stop requires a UUID argument\n")
+ io.WriteString(stderr, "error: ask stop requires an ID or UUID argument\n")
return 1, nil
}
resolved, _, code, err := d.resolveTaskSelector(ctx, args[1], stderr)
@@ -109,7 +109,7 @@ func (d Dispatcher) handleStop(ctx context.Context, args []string, stdout, stder
func (d Dispatcher) handleDone(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
if len(args) < 2 {
- io.WriteString(stderr, "error: ask done requires a UUID argument\n")
+ io.WriteString(stderr, "error: ask done requires an ID or UUID argument\n")
return 1, nil
}
resolved, _, code, err := d.resolveTaskSelector(ctx, args[1], stderr)
@@ -128,7 +128,7 @@ func (d Dispatcher) handleDone(ctx context.Context, args []string, stdout, stder
func (d Dispatcher) handlePriority(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
if len(args) < 3 {
- io.WriteString(stderr, "error: ask priority requires a UUID and priority (H/M/L)\n")
+ io.WriteString(stderr, "error: ask priority requires an ID or UUID and priority (H/M/L)\n")
return 1, nil
}
resolved, _, code, err := d.resolveTaskSelector(ctx, args[1], stderr)
@@ -148,7 +148,7 @@ func (d Dispatcher) handlePriority(ctx context.Context, args []string, stdout, s
func (d Dispatcher) handleTag(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
if len(args) < 3 {
- io.WriteString(stderr, "error: ask tag requires a UUID and +/-tag\n")
+ io.WriteString(stderr, "error: ask tag requires an ID or UUID and +/-tag\n")
return 1, nil
}
resolved, _, code, err := d.resolveTaskSelector(ctx, args[1], stderr)
diff --git a/internal/askcli/command_write_test.go b/internal/askcli/command_write_test.go
index 981df8a..e6b6dd2 100644
--- a/internal/askcli/command_write_test.go
+++ b/internal/askcli/command_write_test.go
@@ -108,6 +108,9 @@ func TestHandleDenotate_MissingArgs(t *testing.T) {
if code != 1 {
t.Fatalf("denotate code = %d, want 1 for missing args", code)
}
+ if !strings.Contains(stderr.String(), "requires an ID or UUID") {
+ t.Fatalf("stderr = %q, want ID-or-UUID message", stderr.String())
+ }
}
func TestHandleModify_Success(t *testing.T) {
@@ -186,6 +189,9 @@ func TestHandleAnnotate_MissingArgs(t *testing.T) {
if code != 1 {
t.Fatalf("annotate code = %d, want 1 for missing args", code)
}
+ if !strings.Contains(stderr.String(), "requires an ID or UUID") {
+ t.Fatalf("stderr = %q, want ID-or-UUID message", stderr.String())
+ }
}
func TestHandleStart_Success(t *testing.T) {
@@ -225,6 +231,9 @@ func TestHandleStart_MissingUUID(t *testing.T) {
if code != 1 {
t.Fatalf("start code = %d, want 1 for missing UUID", code)
}
+ if !strings.Contains(stderr.String(), "requires an ID or UUID") {
+ t.Fatalf("stderr = %q, want ID-or-UUID message", stderr.String())
+ }
}
func TestHandleStop_Success(t *testing.T) {
@@ -288,6 +297,9 @@ func TestHandlePriority_MissingArgs(t *testing.T) {
if code != 1 {
t.Fatalf("priority code = %d, want 1 for missing args", code)
}
+ if !strings.Contains(stderr.String(), "requires an ID or UUID") {
+ t.Fatalf("stderr = %q, want ID-or-UUID message", stderr.String())
+ }
}
func TestHandleTag_Success(t *testing.T) {
diff --git a/internal/askcli/formatter.go b/internal/askcli/formatter.go
index 9e3c245..35ac0ba 100644
--- a/internal/askcli/formatter.go
+++ b/internal/askcli/formatter.go
@@ -194,5 +194,5 @@ func IsNumericID(s string) bool {
}
func RejectNumericID() string {
- return "error: use UUID, not numeric task ID\n"
+ return "error: use a task alias ID or UUID, not a numeric Taskwarrior task ID\n"
}
diff --git a/internal/askcli/formatter_test.go b/internal/askcli/formatter_test.go
index 1d2a22e..cd825ad 100644
--- a/internal/askcli/formatter_test.go
+++ b/internal/askcli/formatter_test.go
@@ -198,8 +198,8 @@ func TestNormalizeUUID(t *testing.T) {
func TestRejectNumericID(t *testing.T) {
output := RejectNumericID()
- if !strings.Contains(output, "use UUID") {
- t.Fatalf("RejectNumericID = %q, want use UUID message", output)
+ if !strings.Contains(output, "task alias ID or UUID") {
+ t.Fatalf("RejectNumericID = %q, want alias-or-UUID message", output)
}
}