diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-26 10:15:58 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-26 10:15:58 +0300 |
| commit | 0088bf27368265511d6ff3c49309df843c528d42 (patch) | |
| tree | 321becbc133e59dc2be31ec27fd1a6a69e8d7ca7 /internal/askcli/commands_registry.go | |
| parent | c4ffb4b994faa3df1760cd1144a8dafcefeb991b (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/commands_registry.go')
| -rw-r--r-- | internal/askcli/commands_registry.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/askcli/commands_registry.go b/internal/askcli/commands_registry.go index 1c2e60d..f999ca3 100644 --- a/internal/askcli/commands_registry.go +++ b/internal/askcli/commands_registry.go @@ -21,6 +21,7 @@ type commandEntry struct { handler commandHandler includeInCompletion bool singleSelector bool + readOnly bool } type commandTable struct { @@ -82,18 +83,21 @@ var commandRegistry = newCommandTable([]commandEntry{ description: "List active tasks", handler: wrapSimpleCommand((*Dispatcher).handleList), includeInCompletion: true, + readOnly: true, }, { name: "all", description: "List all tasks", handler: wrapSimpleCommand((*Dispatcher).handleAll), includeInCompletion: true, + readOnly: true, }, { name: "ready", description: "List READY tasks", handler: wrapSimpleCommand((*Dispatcher).handleReady), includeInCompletion: true, + readOnly: true, }, { name: "info", @@ -101,6 +105,7 @@ var commandRegistry = newCommandTable([]commandEntry{ handler: wrapSimpleCommand((*Dispatcher).handleInfo), includeInCompletion: true, singleSelector: true, + readOnly: true, }, { name: "annotate", @@ -176,11 +181,18 @@ var commandRegistry = newCommandTable([]commandEntry{ description: "List tasks sorted by urgency", handler: wrapSimpleCommand((*Dispatcher).handleUrgency), includeInCompletion: true, + readOnly: true, }, }) func init() { commandRegistry.add(commandEntry{ + name: "watch", + description: "Repeatedly run a subcommand and redraw when output changes", + handler: wrapSimpleCommand((*Dispatcher).handleWatch), + includeInCompletion: true, + }) + commandRegistry.add(commandEntry{ name: "fish", description: "Emit Fish shell completion script", handler: wrapSimpleCommand((*Dispatcher).handleFish), @@ -189,6 +201,7 @@ func init() { commandRegistry.add(commandEntry{ name: "help", description: "Show help", + readOnly: true, handler: func(d *Dispatcher, ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { _ = ctx _ = args |
