Skip to content

Commit

Permalink
fix: Prevent -- from being passed as argument to command
Browse files Browse the repository at this point in the history
  • Loading branch information
ocean committed Aug 4, 2022
1 parent 8ae52e3 commit a562009
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ahoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,11 @@ func getCommands(config Config) []cli.Command {

// c.Args() is not a slice apparently.
for _, arg := range c.Args() {
cmdArgs = append(cmdArgs, arg)
if arg != "--" {
cmdArgs = append(cmdArgs, arg)
}
}
// fmt.Printf("%s : %+v\n", "Args", cmdArgs)

// Replace the entry point placeholders.
cmdEntrypoint = config.Entrypoint[:]
Expand Down Expand Up @@ -254,7 +257,7 @@ func getCommands(config Config) []cli.Command {
newCmd.Subcommands = subCommands
}

//log.Println("found command: ", name, " > ", cmd.Cmd )
// log.Println("found command: ", name, " > ", cmd.Cmd)
exportCmds = append(exportCmds, newCmd)
}

Expand Down Expand Up @@ -378,6 +381,7 @@ func NoArgsAction(c *cli.Context) {
// BeforeCommand runs before every command so arguments or flags must be passed
func BeforeCommand(c *cli.Context) error {
args := c.Args()
// fmt.Printf("%+v\n", args)
if c.Bool("version") {
fmt.Println(version)
return errors.New("don't continue with commands")
Expand All @@ -390,7 +394,7 @@ func BeforeCommand(c *cli.Context) error {
}
return errors.New("don't continue with commands")
}
//fmt.Printf("%+v\n", args)
// fmt.Printf("%+v\n", args)
return nil
}

Expand Down

0 comments on commit a562009

Please sign in to comment.