diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-22 21:21:02 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-22 21:21:02 +0200 |
| commit | 00ff404454c3fc04e13e39992d6dd1200bad9191 (patch) | |
| tree | f59b6a976f38055fe2796bd12de4921c0fb08e8b | |
| parent | 6fd142f00772a1843b2bece2b779189dd5dcbb21 (diff) | |
ask: default to list, add ask all for complete task visibility
- ask (no args) now behaves like ask list (active tasks sorted by priority/urgency)
- ask help: explicit help subcommand
- ask all: shows ALL tasks including completed/deleted (uses status:any)
- handleAll added in command_list.go, mirrors handleList with status:any
- Updated tests: help tests use explicit 'ask help', all subcommand added to reachability test
- Updated help text to document ask all
| -rw-r--r-- | internal/askcli/command_list.go | 29 | ||||
| -rw-r--r-- | internal/askcli/dispatch.go | 9 | ||||
| -rw-r--r-- | internal/askcli/dispatch_test.go | 10 |
3 files changed, 43 insertions, 5 deletions
diff --git a/internal/askcli/command_list.go b/internal/askcli/command_list.go index ee45e6f..e6571e5 100644 --- a/internal/askcli/command_list.go +++ b/internal/askcli/command_list.go @@ -37,6 +37,35 @@ func (d Dispatcher) handleList(ctx context.Context, args []string, stdout, stder return 0, nil } +func (d Dispatcher) handleAll(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) { + filterArgs := []string{"export", "status:any"} + 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 6a99460..d24fec8 100644 --- a/internal/askcli/dispatch.go +++ b/internal/askcli/dispatch.go @@ -24,7 +24,7 @@ func NewDispatcher(runner Runner) *Dispatcher { func (d Dispatcher) Dispatch(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { if len(args) == 0 { - return d.help(stdout) + return d.handleList(ctx, []string{"list"}, stdout, stderr) } subcommand := args[0] switch subcommand { @@ -36,6 +36,8 @@ func (d Dispatcher) Dispatch(ctx context.Context, args []string, stdin io.Reader return d.handleAdd(ctx, args, stdout, stderr) case "list": return d.handleList(ctx, args, stdout, stderr) + case "all": + return d.handleAll(ctx, args, stdout, stderr) case "dep": return d.handleDep(ctx, args, stdout, stderr) case "urgency": @@ -58,6 +60,8 @@ func (d Dispatcher) Dispatch(ctx context.Context, args []string, stdin io.Reader return d.handleDenotate(ctx, args, stdout, stderr) case "delete": return d.handleDelete(ctx, args, stdout, stderr) + case "help": + return d.help(stdout) default: return d.unknownCommand(stderr, subcommand) } @@ -67,7 +71,8 @@ func (d Dispatcher) help(w io.Writer) (int, error) { io.WriteString(w, "ask - task management CLI\n") io.WriteString(w, "\nSubcommands:\n") io.WriteString(w, " ask add \"description\" Create a new task\n") - io.WriteString(w, " ask list [filters] List tasks (UUID-only output)\n") + io.WriteString(w, " ask list [filters] List active tasks (default)\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") io.WriteString(w, " ask start <uuid> Start working on task\n") diff --git a/internal/askcli/dispatch_test.go b/internal/askcli/dispatch_test.go index 4746c67..b1aa820 100644 --- a/internal/askcli/dispatch_test.go +++ b/internal/askcli/dispatch_test.go @@ -11,7 +11,7 @@ import ( func TestDispatcher_Help(t *testing.T) { d := NewDispatcher(nil) var stdout bytes.Buffer - code, err := d.Dispatch(context.Background(), []string{}, nil, &stdout, io.Discard) + code, err := d.Dispatch(context.Background(), []string{"help"}, nil, &stdout, io.Discard) if code != 0 { t.Fatalf("help exit code = %d, want 0", code) } @@ -25,6 +25,9 @@ func TestDispatcher_Help(t *testing.T) { if !strings.Contains(output, "ask list") { t.Fatalf("help missing list subcommand: %s", output) } + if !strings.Contains(output, "ask all") { + t.Fatalf("help missing all subcommand: %s", output) + } if !strings.Contains(output, "Filters:") { t.Fatalf("help missing Filters section: %s", output) } @@ -49,9 +52,9 @@ func TestDispatcher_UnknownSubcommand(t *testing.T) { func TestDispatcher_LongHelp(t *testing.T) { d := NewDispatcher(nil) var stdout bytes.Buffer - d.Dispatch(context.Background(), []string{}, nil, &stdout, io.Discard) + d.Dispatch(context.Background(), []string{"help"}, nil, &stdout, io.Discard) output := stdout.String() - for _, sub := range []string{"add", "list", "info", "annotate", "start", "stop", "done", "priority", "tag", "dep", "urgency", "modify", "denotate", "delete", "export"} { + for _, sub := range []string{"add", "list", "all", "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) } @@ -72,6 +75,7 @@ func TestDispatcher_AllSubcommandsReachExecutor(t *testing.T) { "tag": {"tag", "test-uuid", "+cli"}, "dep": {"dep", "list", "test-uuid"}, "list": {"list"}, + "all": {"all"}, "urgency": {"urgency"}, "info": {"info", "test-uuid"}, "add": {"add", "new task description"}, |
