feat(cli): add normalizeVerb alias helper

This commit is contained in:
2026-06-27 11:40:42 +01:00
parent 2c7b8d3610
commit 68c926f83b
2 changed files with 28 additions and 0 deletions
+12
View File
@@ -16,3 +16,15 @@ func uintSlice(us []uint32) []uint64 {
} }
return out return out
} }
// normalizeVerb maps verb aliases to their canonical form. Applied at the
// subcommand-verb position of every admin group and at the top-level command.
func normalizeVerb(v string) string {
switch v {
case "rm", "del":
return "remove"
case "ls":
return "list"
}
return v
}
+16
View File
@@ -0,0 +1,16 @@
package cli
import "testing"
func TestNormalizeVerb(t *testing.T) {
cases := map[string]string{
"rm": "remove", "del": "remove", "remove": "remove",
"ls": "list", "list": "list",
"add": "add", "enable": "enable", "": "",
}
for in, want := range cases {
if got := normalizeVerb(in); got != want {
t.Errorf("normalizeVerb(%q) = %q, want %q", in, got, want)
}
}
}