Switches CLI flag parsing from Go's stdlib `flag` to spf13/pflag so `--project` (and the internal `--socket` / `--identity` / `--scenario` flags) are the only accepted form; single-hyphen long flags like `-project` are now rejected. Help output renders the canonical `--` form. Adds `patterm --version`, which prints the build version, short commit, and build date (e.g. `patterm v0.0.1 (commit abc1234, built 2026-05-14)`). The version string is injected at build time — `make patterm` derives it from `git describe --tags --always --dirty`, and the release workflow injects the pushed tag. Commit/date come from the Go toolchain's embedded VCS info via `runtime/debug.ReadBuildInfo`, so no manual bumping is required.
49 lines
1010 B
Go
49 lines
1010 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
|
|
flag "github.com/spf13/pflag"
|
|
|
|
"github.com/hjbdev/patterm/internal/harness"
|
|
)
|
|
|
|
func runDebugHarness() {
|
|
var (
|
|
scenarioPath = flag.String("scenario", "", "JSON scenario path")
|
|
pattermBin = flag.String("patterm-bin", "", "patterm binary under test (default: this executable)")
|
|
)
|
|
flag.Parse()
|
|
if *scenarioPath == "" {
|
|
die("debug-harness: --scenario is required")
|
|
}
|
|
if *pattermBin == "" {
|
|
exe, err := os.Executable()
|
|
if err != nil {
|
|
die("debug-harness: os.Executable: %v", err)
|
|
}
|
|
*pattermBin = exe
|
|
}
|
|
sc, err := harness.LoadScenario(*scenarioPath)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stdout, "{\"ok\":false,\"error\":%q}\n", err.Error())
|
|
os.Exit(2)
|
|
}
|
|
enc := json.NewEncoder(os.Stdout)
|
|
res, err := harness.RunScenario(harness.Options{
|
|
Scenario: sc,
|
|
PattermBin: *pattermBin,
|
|
}, func(ev harness.Event) {
|
|
_ = enc.Encode(ev)
|
|
})
|
|
_ = enc.Encode(res)
|
|
if err != nil {
|
|
if res.Steps == 0 {
|
|
os.Exit(2)
|
|
}
|
|
os.Exit(1)
|
|
}
|
|
}
|