diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-22 20:51:38 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-22 20:51:38 +0200 |
| commit | b5932f24276896468ce75f9aceea2efb1fc6f44f (patch) | |
| tree | 4747789a708f037c235211da6112e1cf46d88929 /cmd/ask/main.go | |
| parent | 3e400433b1107274c28d6b8dd03839e442cbba0f (diff) | |
cmd/ask: wire to askcli.Dispatch, remove taskproxy passthrough
Diffstat (limited to 'cmd/ask/main.go')
| -rw-r--r-- | cmd/ask/main.go | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/cmd/ask/main.go b/cmd/ask/main.go index 73d3e04..72b67e3 100644 --- a/cmd/ask/main.go +++ b/cmd/ask/main.go @@ -2,45 +2,18 @@ package main import ( "context" - "fmt" - "io" "os" - "codeberg.org/snonux/hexai/internal/taskproxy" + "codeberg.org/snonux/hexai/internal/askcli" ) -type taskRunner func(context.Context, []string, io.Reader, io.Writer, io.Writer) (int, error) - -type askRunner struct { - runTask taskRunner -} - -func newAskRunner() askRunner { - return askRunner{runTask: runAskTask} -} - func main() { - if exitCode := newAskRunner().run(os.Args[1:], os.Stdin, os.Stdout, os.Stderr); exitCode != 0 { - os.Exit(exitCode) - } -} - -func (r askRunner) run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { - runner := normalizeAskRunner(r) - exitCode, err := runner.runTask(context.Background(), args, stdin, stdout, stderr) + d := askcli.NewDispatcher(nil) + code, err := d.Dispatch(context.Background(), os.Args[1:], os.Stdin, os.Stdout, os.Stderr) if err != nil { - fmt.Fprintln(stderr, err) + os.Exit(code) } - return exitCode -} - -func normalizeAskRunner(r askRunner) askRunner { - if r.runTask == nil { - r.runTask = runAskTask + if code != 0 { + os.Exit(code) } - return r -} - -func runAskTask(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { - return taskproxy.NewRunner("ask").Run(ctx, args, stdin, stdout, stderr) } |
