diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-27 11:33:33 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-27 11:33:33 +0200 |
| commit | f57ccb885d20c48e1dae65b8ad5c46375b9a11a9 (patch) | |
| tree | a023c5f5af65cfe8f20354c388c683c57437e5d2 /internal/askcli/dispatch.go | |
| parent | 56e9f980e52a53197ace71acdb277ba0e0368916 (diff) | |
docs: document askcli exports
Diffstat (limited to 'internal/askcli/dispatch.go')
| -rw-r--r-- | internal/askcli/dispatch.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/askcli/dispatch.go b/internal/askcli/dispatch.go index 4612555..142f7b4 100644 --- a/internal/askcli/dispatch.go +++ b/internal/askcli/dispatch.go @@ -6,15 +6,20 @@ import ( "io" ) +// Runner performs CLI work that would otherwise be handled by ask itself. +// +// The interface is implemented by the executor that ultimately proxies commands to Taskwarrior. type Runner interface { Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) } +// Dispatcher translates CLI arguments into concrete subcommands and presents the output. type Dispatcher struct { runner Runner jsonOutput bool } +// NewDispatcher creates a Dispatcher backed by the provided Runner or a default executor when nil. func NewDispatcher(runner Runner) *Dispatcher { if runner == nil { e := NewExecutor("ask") @@ -36,6 +41,7 @@ func parseGlobalFlags(args []string) ([]string, bool) { return filtered, jsonOutput } +// Dispatch parses CLI arguments, handles global flags, and routes the request to the matching subcommand. func (d *Dispatcher) Dispatch(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { args, jsonOutput := parseGlobalFlags(args) d.jsonOutput = jsonOutput |
