summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-22 21:22:04 +0200
committerPaul Buetow <paul@buetow.org>2026-03-22 21:22:04 +0200
commit641e5f723215960713ad183d6d99619b64d69467 (patch)
treebb1dfd79fd9789f2e9a2625123f69e3f784d4984
parent00ff404454c3fc04e13e39992d6dd1200bad9191 (diff)
ask: add ready command to list READY tasks (not blocked)
handleReady passes +READY filter to show actionable tasks only. help text updated. tests updated.
-rw-r--r--internal/askcli/command_list.go29
-rw-r--r--internal/askcli/dispatch.go3
-rw-r--r--internal/askcli/dispatch_test.go3
3 files changed, 34 insertions, 1 deletions
diff --git a/internal/askcli/command_list.go b/internal/askcli/command_list.go
index e6571e5..1ba9352 100644
--- a/internal/askcli/command_list.go
+++ b/internal/askcli/command_list.go
@@ -66,6 +66,35 @@ func (d Dispatcher) handleAll(ctx context.Context, args []string, stdout, stderr
return 0, nil
}
+func (d Dispatcher) handleReady(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
+ filterArgs := []string{"export", "+READY"}
+ for _, arg := range args[1:] {
+ if strings.HasPrefix(arg, "limit:") || strings.HasPrefix(arg, "sort:") ||
+ strings.HasPrefix(arg, "+") || arg == "started" {
+ filterArgs = append(filterArgs, arg)
+ }
+ }
+ var outBuf bytes.Buffer
+ code, err := d.runner.Run(ctx, filterArgs, nil, &outBuf, stderr)
+ if code != 0 {
+ return code, err
+ }
+ tasks, err := ParseTaskExport(&outBuf)
+ if err != nil {
+ return 1, nil
+ }
+ sort.Slice(tasks, func(i, j int) bool {
+ pi := priorityOrder(tasks[i].Priority)
+ pj := priorityOrder(tasks[j].Priority)
+ if pi != pj {
+ return pi < pj
+ }
+ return tasks[i].Urgency > tasks[j].Urgency
+ })
+ io.WriteString(stdout, FormatTaskList(tasks))
+ return 0, nil
+}
+
func priorityOrder(p string) int {
switch p {
case "H":
diff --git a/internal/askcli/dispatch.go b/internal/askcli/dispatch.go
index d24fec8..42097c5 100644
--- a/internal/askcli/dispatch.go
+++ b/internal/askcli/dispatch.go
@@ -38,6 +38,8 @@ func (d Dispatcher) Dispatch(ctx context.Context, args []string, stdin io.Reader
return d.handleList(ctx, args, stdout, stderr)
case "all":
return d.handleAll(ctx, args, stdout, stderr)
+ case "ready":
+ return d.handleReady(ctx, args, stdout, stderr)
case "dep":
return d.handleDep(ctx, args, stdout, stderr)
case "urgency":
@@ -72,6 +74,7 @@ func (d Dispatcher) help(w io.Writer) (int, error) {
io.WriteString(w, "\nSubcommands:\n")
io.WriteString(w, " ask add \"description\" Create a new task\n")
io.WriteString(w, " ask list [filters] List active tasks (default)\n")
+ io.WriteString(w, " ask ready List READY tasks (not blocked)\n")
io.WriteString(w, " ask all [filters] List all tasks including completed/deleted\n")
io.WriteString(w, " ask info <uuid> Show task details\n")
io.WriteString(w, " ask annotate <uuid> \"note\" Add annotation to task\n")
diff --git a/internal/askcli/dispatch_test.go b/internal/askcli/dispatch_test.go
index b1aa820..005a88c 100644
--- a/internal/askcli/dispatch_test.go
+++ b/internal/askcli/dispatch_test.go
@@ -54,7 +54,7 @@ func TestDispatcher_LongHelp(t *testing.T) {
var stdout bytes.Buffer
d.Dispatch(context.Background(), []string{"help"}, nil, &stdout, io.Discard)
output := stdout.String()
- for _, sub := range []string{"add", "list", "all", "info", "annotate", "start", "stop", "done", "priority", "tag", "dep", "urgency", "modify", "denotate", "delete", "export"} {
+ for _, sub := range []string{"add", "list", "all", "ready", "info", "annotate", "start", "stop", "done", "priority", "tag", "dep", "urgency", "modify", "denotate", "delete", "export"} {
if !strings.Contains(output, "ask "+sub) {
t.Errorf("help missing subcommand: ask %s", sub)
}
@@ -76,6 +76,7 @@ func TestDispatcher_AllSubcommandsReachExecutor(t *testing.T) {
"dep": {"dep", "list", "test-uuid"},
"list": {"list"},
"all": {"all"},
+ "ready": {"ready"},
"urgency": {"urgency"},
"info": {"info", "test-uuid"},
"add": {"add", "new task description"},