mirror of
https://github.com/MobAI-App/simslim.git
synced 2026-09-27 17:02:00 +02:00
Replace the hand-rolled argument handling with the urfave/cli/v3 command tree (the project's only dependency; no runtime transitive deps). This removes the manual command switch, parseInterspersedFlags, jsonOption, and extractDeviceSets in favor of the library's dispatch and flag parsing. The command surface is unchanged: same commands, flags, arguments, JSON output, error format (simslim: <msg>, exit 1), and unknown-command/usage handling (exit 2). Flags may still appear before or after positional args (v3 parses flags anywhere by default). --set is now a global flag inherited by every subcommand, registered in its flag Action with last-wins, comma-separated semantics. main still owns version, help, and the macOS guard; the root usage text is preserved verbatim. The command tree lives in app.go (newApp); each subcommand's Action is a cmd* function in main.go reading flags via cmd.Bool/String and positionals via cmd.Args(). Unit tests for the removed helpers are replaced by app_test.go, which drives newApp through Run.
21 lines
506 B
Go
21 lines
506 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestTruncatePreservesUnicode(t *testing.T) {
|
|
if got, want := truncate("模拟器名称", 4), "模拟器…"; got != want {
|
|
t.Fatalf("truncate() = %q, want %q", got, want)
|
|
}
|
|
if got, want := truncate("short", 10), "short"; got != want {
|
|
t.Fatalf("truncate() = %q, want %q", got, want)
|
|
}
|
|
}
|
|
|
|
func TestHumanBytesIncludesKilobytes(t *testing.T) {
|
|
if got, want := humanBytes(8<<10), "8 KB"; got != want {
|
|
t.Fatalf("humanBytes() = %q, want %q", got, want)
|
|
}
|
|
}
|