From 2a8237c0090adf00a7f32f6513c3de9388fcf284 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Mon, 27 Jun 2022 23:11:44 +0200 Subject: [PATCH 1/2] Update doc comment --- acmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acmd.go b/acmd.go index ed8d620..0b72e27 100644 --- a/acmd.go +++ b/acmd.go @@ -39,7 +39,7 @@ type Command struct { // Do will be invoked. Do func(ctx context.Context, args []string) error - // subcommands of the command. + // Subcommands of the command. Subcommands []Command // IsHidden reports whether command should not be show in help. Default false. From 889426d64202ab770542a6272d6c67976bb896f0 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Mon, 27 Jun 2022 23:14:35 +0200 Subject: [PATCH 2/2] Relax command name format --- acmd.go | 2 +- acmd_test.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/acmd.go b/acmd.go index 0b72e27..8ed54a0 100644 --- a/acmd.go +++ b/acmd.go @@ -241,7 +241,7 @@ func isStringValid(s string) bool { } for _, c := range s { if !(('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || - ('0' <= c && c <= '9') || c == '-' || c == '_') { + ('0' <= c && c <= '9') || c == '-' || c == '_' || c == ':') { return false } } diff --git a/acmd_test.go b/acmd_test.go index 3f90c0e..17d98a9 100644 --- a/acmd_test.go +++ b/acmd_test.go @@ -204,6 +204,10 @@ func TestRunnerInit(t *testing.T) { cfg Config wantErrStr string }{ + { + cmds: []Command{{Name: "app:create", Do: nopFunc}}, + wantErrStr: ``, + }, { cmds: []Command{{Name: "", Do: nopFunc}}, wantErrStr: `command "" must contains only letters, digits, - and _`, @@ -276,7 +280,7 @@ func TestRunnerInit(t *testing.T) { for _, tc := range testCases { err := RunnerOf(tc.cmds, tc.cfg).Run() - if got := err.Error(); !strings.Contains(got, tc.wantErrStr) { + if got := err.Error(); tc.wantErrStr != "" && !strings.Contains(got, tc.wantErrStr) { t.Fatalf("want %q got %q", tc.wantErrStr, got) } }