Skip to content

Commit

Permalink
Issue #50: Provide a check that ensures that either cmd or imports mu…
Browse files Browse the repository at this point in the history
…st be set for a command.
  • Loading branch information
Frank Carey committed Jan 22, 2017
1 parent 1a10293 commit a0267b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ahoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ func getCommands(config Config) []cli.Command {
for _, name := range keys {
cmd := config.Commands[name]

// Check that a command has 'cmd' OR 'imports' set.
if cmd.Cmd == "" && cmd.Imports == nil {
logger("fatal", "Command ["+name+"] has neither 'cmd' or 'imports' set. Check your yaml file.")
}

newCmd := cli.Command{
Name: name,
SkipFlagParsing: true,
Expand Down
1 change: 1 addition & 0 deletions tests/missing-cmd.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
[ $status -ne 0 ]
echo "${lines[@]}"
[ "${lines[0]}" != "panic: runtime error: invalid memory address or nil pointer dereference" ]
[ "${lines[0]}" == "[fatal] Command [missing-completely] has neither 'cmd' or 'imports' set. Check your yaml file." ]
}

0 comments on commit a0267b5

Please sign in to comment.