From 68c926f83bbfdd132ca8de8c224c10cb940f8172 Mon Sep 17 00:00:00 2001 From: Steve Cliff Date: Sat, 27 Jun 2026 11:40:42 +0100 Subject: [PATCH] feat(cli): add normalizeVerb alias helper --- internal/cli/dispatch.go | 12 ++++++++++++ internal/cli/dispatch_test.go | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 internal/cli/dispatch_test.go diff --git a/internal/cli/dispatch.go b/internal/cli/dispatch.go index 56cacc6..a8af273 100644 --- a/internal/cli/dispatch.go +++ b/internal/cli/dispatch.go @@ -16,3 +16,15 @@ func uintSlice(us []uint32) []uint64 { } 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 +} diff --git a/internal/cli/dispatch_test.go b/internal/cli/dispatch_test.go new file mode 100644 index 0000000..99a6ed1 --- /dev/null +++ b/internal/cli/dispatch_test.go @@ -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) + } + } +}