summaryrefslogtreecommitdiff
path: root/cmd/ask/main.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-19 09:26:26 +0200
committerPaul Buetow <paul@buetow.org>2026-03-19 09:26:26 +0200
commit15bc73d103259b492f8b77a422f8649bdf3d7c24 (patch)
tree58a834d1cab371ce9acc2b25780524223c06980c /cmd/ask/main.go
parent5642eaf74a4a70e5c82646bef3e0dd42846baea8 (diff)
Add ask Taskwarrior wrapper
Diffstat (limited to 'cmd/ask/main.go')
-rw-r--r--cmd/ask/main.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/cmd/ask/main.go b/cmd/ask/main.go
new file mode 100644
index 0000000..73d3e04
--- /dev/null
+++ b/cmd/ask/main.go
@@ -0,0 +1,46 @@
+package main
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "os"
+
+ "codeberg.org/snonux/hexai/internal/taskproxy"
+)
+
+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)
+ if err != nil {
+ fmt.Fprintln(stderr, err)
+ }
+ return exitCode
+}
+
+func normalizeAskRunner(r askRunner) askRunner {
+ if r.runTask == nil {
+ r.runTask = runAskTask
+ }
+ 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)
+}