feat(cli): wire arch-binary subcommand

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <[email protected]>
This commit is contained in:
2026-08-19 18:24:45 -04:00
co-authored by Sisyphus
parent 8ee8ec30db
commit 38ddc7cfb2
2 changed files with 94 additions and 1 deletions
+60
View File
@@ -0,0 +1,60 @@
package main
import (
"reflect"
"testing"
)
func TestNormalizeArgs(t *testing.T) {
valueFlags := map[string]bool{
"--output": true,
"--repo": true,
"--arch": true,
}
tests := []struct {
name string
in []string
want []string
}{
{
name: "flags after positional",
in: []string{"input.pkg.tar.zst", "--output", "/tmp/out"},
want: []string{"--output", "/tmp/out", "input.pkg.tar.zst"},
},
{
name: "flags before positional",
in: []string{"--output", "/tmp/out", "input.pkg.tar.zst"},
want: []string{"--output", "/tmp/out", "input.pkg.tar.zst"},
},
{
name: "flag=value form",
in: []string{"input.pkg.tar.zst", "--output=/tmp/out"},
want: []string{"--output=/tmp/out", "input.pkg.tar.zst"},
},
{
name: "unknown flag stays a flag",
in: []string{"input.pkg.tar.zst", "--bogus"},
want: []string{"--bogus", "input.pkg.tar.zst"},
},
{
name: "value-taking flag at end without value",
in: []string{"input.pkg.tar.zst", "--output"},
want: []string{"--output", "input.pkg.tar.zst"},
},
{
name: "mixed flags and positionals keep order",
in: []string{"--repo", "https://x", "a.zst", "--output", "/tmp/out", "b.zst"},
want: []string{"--repo", "https://x", "--output", "/tmp/out", "a.zst", "b.zst"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := normalizeArgs(tt.in, valueFlags)
if !reflect.DeepEqual(got, tt.want) {
t.Fatalf("normalizeArgs(%v) = %v, want %v", tt.in, got, tt.want)
}
})
}
}