summaryrefslogtreecommitdiff
path: root/internal/askcli
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-22 22:26:19 +0200
committerPaul Buetow <paul@buetow.org>2026-03-22 22:26:19 +0200
commita0f7ee1cd4b0833ff45b94e2a35c60227e6ec1e3 (patch)
treecf85a206d88431dc88c6d882d07ff2a9fb70f331 /internal/askcli
parentf6ce62d4e5cefc4a7761bbb86f329ad08ba57570 (diff)
ask list: only show pending tasks by defaultv0.25.3
Add status:pending filter to list command so it only shows pending tasks, not completed or deleted ones. Use 'ask all' to see all tasks.
Diffstat (limited to 'internal/askcli')
-rw-r--r--internal/askcli/command_list.go2
-rw-r--r--internal/askcli/command_list_test.go32
2 files changed, 25 insertions, 9 deletions
diff --git a/internal/askcli/command_list.go b/internal/askcli/command_list.go
index b5c5429..82b7ff5 100644
--- a/internal/askcli/command_list.go
+++ b/internal/askcli/command_list.go
@@ -9,7 +9,7 @@ import (
)
func (d Dispatcher) handleList(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
- filterArgs := []string{"export"}
+ filterArgs := []string{"status:pending", "export"}
for _, arg := range args[1:] {
if strings.HasPrefix(arg, "limit:") || strings.HasPrefix(arg, "sort:") ||
strings.HasPrefix(arg, "+") || arg == "started" {
diff --git a/internal/askcli/command_list_test.go b/internal/askcli/command_list_test.go
index 745a402..e6bce83 100644
--- a/internal/askcli/command_list_test.go
+++ b/internal/askcli/command_list_test.go
@@ -11,8 +11,11 @@ import (
func TestHandleList_Success(t *testing.T) {
jsonData := `[{"uuid":"uuid-1","description":"Task 1","status":"pending","priority":"H","tags":["cli"],"urgency":15.0,"depends":[]},{"uuid":"uuid-2","description":"Task 2","status":"completed","priority":"M","tags":["agent"],"urgency":10.0,"depends":[]}]`
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
- if args[0] == "export" {
- io.WriteString(stdout, jsonData)
+ for _, arg := range args {
+ if arg == "export" {
+ io.WriteString(stdout, jsonData)
+ return 0, nil
+ }
}
return 0, nil
}})
@@ -30,8 +33,11 @@ func TestHandleList_Success(t *testing.T) {
func TestHandleList_SortedByPriority(t *testing.T) {
jsonData := `[{"uuid":"uuid-2","description":"Task 2","status":"pending","priority":"M","tags":[],"urgency":10.0,"depends":[]},{"uuid":"uuid-1","description":"Task 1","status":"pending","priority":"H","tags":[],"urgency":5.0,"depends":[]}]`
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
- if args[0] == "export" {
- io.WriteString(stdout, jsonData)
+ for _, arg := range args {
+ if arg == "export" {
+ io.WriteString(stdout, jsonData)
+ return 0, nil
+ }
}
return 0, nil
}})
@@ -47,8 +53,11 @@ func TestHandleList_SortedByPriority(t *testing.T) {
func TestHandleList_EmptyList(t *testing.T) {
d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
- if args[0] == "export" {
- io.WriteString(stdout, "[]")
+ for _, arg := range args {
+ if arg == "export" {
+ io.WriteString(stdout, "[]")
+ return 0, nil
+ }
}
return 0, nil
}})
@@ -71,7 +80,14 @@ func TestHandleList_PassesFilters(t *testing.T) {
if len(capturedArgs) < 2 {
t.Fatalf("expected export args, got %v", capturedArgs)
}
- if capturedArgs[0] != "export" {
- t.Fatalf("first arg should be export, got %s", capturedArgs[0])
+ hasExport := false
+ for _, arg := range capturedArgs {
+ if arg == "export" {
+ hasExport = true
+ break
+ }
+ }
+ if !hasExport {
+ t.Fatalf("expected export in args, got %v", capturedArgs)
}
}