Skip to content

Commit

Permalink
Relax command name format
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Jun 27, 2022
1 parent 2a8237c commit 889426d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion acmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
6 changes: 5 additions & 1 deletion acmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 _`,
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 889426d

Please sign in to comment.