Skip to content

Commit 85e5a2e

Browse files
committed
chore: Improve wording and the exit status
Signed-off-by: Drew Robinson <drew.robinson@gmail.com>
1 parent 0e4923f commit 85e5a2e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

ahoy.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ func getSubCommands(includes []string) []cli.Command {
143143
if len(include) == 0 {
144144
continue
145145
}
146-
if include[0] != "/"[0] || include[0] != "~"[0] {
146+
// If the include path is not absolute or a home directory path,
147+
// prepend the source directory to make it relative to the config file.
148+
if !strings.HasPrefix(include, "/") && !strings.HasPrefix(include, "~") {
147149
include = filepath.Join(AhoyConf.srcDir, include)
148150
}
149151
if _, err := os.Stat(include); err != nil {
@@ -186,7 +188,7 @@ func getCommands(config Config) []cli.Command {
186188
logger("fatal", "Command ["+name+"] has neither 'cmd' or 'imports' set. Check your yaml file.")
187189
}
188190

189-
// Check that a command has 'cmd' OR 'imports' set.
191+
// Check that a command has 'cmd' AND 'imports' set.
190192
if cmd.Cmd != "" && cmd.Imports != nil {
191193
logger("fatal", "Command ["+name+"] has both 'cmd' and 'imports' set, but only one is allowed. Check your yaml file.")
192194
}
@@ -262,7 +264,7 @@ func getCommands(config Config) []cli.Command {
262264
newCmd.Subcommands = subCommands
263265
}
264266

265-
// log.Println("found command: ", name, " > ", cmd.Cmd)
267+
// log.Println("Source file:", sourcefile, "- found command:", name, ">", cmd.Cmd)
266268
exportCmds = append(exportCmds, newCmd)
267269
}
268270

@@ -376,11 +378,12 @@ func NoArgsAction(c *cli.Context) {
376378
}
377379

378380
if !c.Bool("help") || !c.Bool("version") {
379-
logger("fatal", "Missing flag or argument.")
381+
logger("warn", "Missing flag or argument.")
382+
os.Exit(1)
380383
}
381384

382-
// Looks like we never reach here.
383-
fmt.Println("ERROR: NoArg Action ")
385+
// Exit gracefully if we get to here.
386+
os.Exit(0)
384387
}
385388

386389
// BeforeCommand runs before every command so arguments or flags must be passed

0 commit comments

Comments
 (0)