Skip to content

Commit

Permalink
Exit after usage() is shown. Fixes #3583
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Lo-A-Foe <[email protected]>
  • Loading branch information
loafoe committed Sep 6, 2024
1 parent 8aed3dd commit 3c2696f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
33 changes: 17 additions & 16 deletions cmd/goa/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,26 @@ func main() {
path string
offset int
)
{
if len(os.Args) == 1 {
usage()
}
if len(os.Args) == 1 {
usage()
return
}

switch os.Args[1] {
case "version":
fmt.Println("Goa version " + goa.Version())
os.Exit(0)
case "gen", "example":
if len(os.Args) == 2 {
usage()
}
cmd = os.Args[1]
path = os.Args[2]
offset = 2
default:
switch os.Args[1] {
case "version":
fmt.Println("Goa version " + goa.Version())
os.Exit(0)
case "gen", "example":
if len(os.Args) == 2 {
usage()
return
}
cmd = os.Args[1]
path = os.Args[2]
offset = 2
default:
usage()
return
}

var (
Expand Down
6 changes: 3 additions & 3 deletions cmd/goa/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func TestCmdLine(t *testing.T) {
}{
"gen": {"gen " + testPkg, false, "gen", testPkg, ".", false},

"invalid": {"invalid " + testPkg, true, "", "", ".", false},
"empty": {"", true, "", "", ".", false},
"invalid gen": {"invalid gen" + testPkg, true, "", "", ".", false},
"invalid": {"invalid " + testPkg, true, "", "", "", false},
"empty": {"", true, "", "", "", false},
"invalid gen": {"invalid gen" + testPkg, true, "", "", "", false},

"output": {"gen " + testPkg + " -output " + testOutput, false, "gen", testPkg, testOutput, false},
"output short": {"gen " + testPkg + " -o " + testOutput, false, "gen", testPkg, testOutput, false},
Expand Down

0 comments on commit 3c2696f

Please sign in to comment.