summaryrefslogtreecommitdiff
path: root/internal/askcli/dispatch.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-26 10:15:58 +0300
committerPaul Buetow <paul@buetow.org>2026-05-26 10:15:58 +0300
commit0088bf27368265511d6ff3c49309df843c528d42 (patch)
tree321becbc133e59dc2be31ec27fd1a6a69e8d7ca7 /internal/askcli/dispatch.go
parentc4ffb4b994faa3df1760cd1144a8dafcefeb991b (diff)
feat(askcli): add watch subcommand
Implements `ask watch [subcommand...]` which re-runs a read-only subcommand every 2 seconds and redraws output when it changes, similar to gnu-watch. Safety features: - Restricted to read-only subcommands (list, all, ready, info, urgency, help, dep list) - Recursive watch is blocked - Captures stderr so error messages are visible in the watched display Also adds readOnly field to commandEntry registry for maintainability.
Diffstat (limited to 'internal/askcli/dispatch.go')
-rw-r--r--internal/askcli/dispatch.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/askcli/dispatch.go b/internal/askcli/dispatch.go
index cd2aae7..2cdaa93 100644
--- a/internal/askcli/dispatch.go
+++ b/internal/askcli/dispatch.go
@@ -54,6 +54,10 @@ func (d *Dispatcher) Dispatch(ctx context.Context, args []string, stdin io.Reade
if len(args) == 0 {
args = []string{"list"}
}
+ return d.dispatchCommand(ctx, args, stdin, stdout, stderr)
+}
+
+func (d *Dispatcher) dispatchCommand(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
subcommand := args[0]
entry, ok := commandRegistry.get(subcommand)
if !ok {
@@ -90,6 +94,7 @@ func (d *Dispatcher) help(w io.Writer) (int, error) {
_, _ = io.WriteString(w, " ask dep rm <id|uuid> <dep> Remove dependency\n")
_, _ = io.WriteString(w, " ask dep list <id|uuid> List dependencies\n")
_, _ = io.WriteString(w, " ask urgency List tasks sorted by urgency\n")
+ _, _ = io.WriteString(w, " ask watch [subcommand...] Re-run a read-only subcommand every 2s and redraw on changes\n")
_, _ = io.WriteString(w, " ask modify <id|uuid> <args...> Modify task fields\n")
_, _ = io.WriteString(w, " ask denotate <id|uuid> \"text\" Remove annotation\n")
_, _ = io.WriteString(w, " ask delete <id|uuid> Delete a task\n")