summaryrefslogtreecommitdiff
path: root/internal/askcli/command_list.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-24 17:44:37 +0200
committerPaul Buetow <paul@buetow.org>2026-03-24 17:44:37 +0200
commitbef3cc7dd95745a5724d3569e45fe7be4aba02ee (patch)
tree36ec4a6dc5b42eeec88ea0424287f317a4807320 /internal/askcli/command_list.go
parent5beb39a3338e83c9a5906d2e5f7acb3bf795811d (diff)
ask: add --json flag for machine-readable outputv0.25.12
List, ready, all, info, and urgency commands now output JSON arrays when --json is passed. This fixes pi agent-plan-mode extension which expects JSON from ask but was getting human-readable tables. Amp-Thread-ID: https://ampcode.com/threads/T-019d207c-b8e2-748d-af52-dd8f84fb2b32 Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'internal/askcli/command_list.go')
-rw-r--r--internal/askcli/command_list.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/internal/askcli/command_list.go b/internal/askcli/command_list.go
index 54eaafc..ef8c22f 100644
--- a/internal/askcli/command_list.go
+++ b/internal/askcli/command_list.go
@@ -3,6 +3,7 @@ package askcli
import (
"bytes"
"context"
+ "encoding/json"
"fmt"
"io"
"sort"
@@ -51,7 +52,17 @@ func (d Dispatcher) handleListWithFilters(ctx context.Context, initialFilters, e
}
return tasks[i].Urgency > tasks[j].Urgency
})
- io.WriteString(stdout, FormatTaskList(tasks))
+ if d.jsonOutput {
+ data, err := json.Marshal(tasks)
+ if err != nil {
+ fmt.Fprintf(stderr, "error: failed to marshal JSON: %v\n", err)
+ return 1, nil
+ }
+ stdout.Write(data)
+ io.WriteString(stdout, "\n")
+ } else {
+ io.WriteString(stdout, FormatTaskList(tasks))
+ }
return 0, nil
}