summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-13 22:22:38 +0200
committerPaul Buetow <paul@buetow.org>2026-03-13 22:22:38 +0200
commit8ae4be9684a58d44985e5b5ee5e90f74555b2dde (patch)
tree06029d949bdd549c835855d4b158e3234e277094 /cmd
parent4d0f11822c1cdf4c51028bde8881756941314821 (diff)
release: v0.22.0v0.22.0
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hexai/main.go4
-rw-r--r--cmd/hexai/main_test.go19
2 files changed, 23 insertions, 0 deletions
diff --git a/cmd/hexai/main.go b/cmd/hexai/main.go
index de96bbf..874c850 100644
--- a/cmd/hexai/main.go
+++ b/cmd/hexai/main.go
@@ -27,6 +27,7 @@ func main() {
fs := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
defaultPath := appconfig.DefaultConfigPath()
configFlag := fs.String("config", configPath, fmt.Sprintf("path to config file (default: %s)", defaultPath))
+ tpsSimulation := fs.String("tps-simulation", "", "simulate stdout at a token-per-second rate; accepts '12' or '10-20'")
showVersion := fs.Bool("version", false, "print version and exit")
selectedFlags := make([]bool, len(cliEntries))
for i, entry := range cliEntries {
@@ -61,6 +62,9 @@ func main() {
if finalPath != "" {
ctx = hexaicli.WithCLIConfigPath(ctx, finalPath)
}
+ if strings.TrimSpace(*tpsSimulation) != "" {
+ ctx = hexaicli.WithCLITPSSimulation(ctx, *tpsSimulation)
+ }
if len(selection) > 0 {
ctx = hexaicli.WithCLISelection(ctx, selection)
}
diff --git a/cmd/hexai/main_test.go b/cmd/hexai/main_test.go
index 797584f..531a11f 100644
--- a/cmd/hexai/main_test.go
+++ b/cmd/hexai/main_test.go
@@ -3,6 +3,7 @@ package main
import (
"io"
"os"
+ "strings"
"testing"
)
@@ -23,3 +24,21 @@ func TestMain_Version(t *testing.T) {
t.Fatalf("expected version output")
}
}
+
+func TestMain_TPSSimulation(t *testing.T) {
+ oldArgs := os.Args
+ defer func() { os.Args = oldArgs }()
+ os.Args = []string{"hexai", "--tps-simulation=1000000", "simulated", "output"}
+ r, w, _ := os.Pipe()
+ old := os.Stdout
+ os.Stdout = w
+ defer func() { os.Stdout = old }()
+ main()
+ if err := w.Close(); err != nil {
+ t.Fatalf("failed to close pipe: %v", err)
+ }
+ b, _ := io.ReadAll(r)
+ if !strings.Contains(string(b), "simulated output") {
+ t.Fatalf("expected simulation output, got %q", string(b))
+ }
+}