Skip to content

Commit

Permalink
updated: No more commands with the same name will be added.
Browse files Browse the repository at this point in the history
  • Loading branch information
yigit433 committed Aug 3, 2022
1 parent a03d098 commit 930e376
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ type Config struct {
}

func (c *Config) AddCommand(cmd *Command) {
c.commands = append(c.commands, *cmd)
for i, c := range c.commands {
if c.Name == cmd.Name {
panic("There is a command with the name you are trying to add.")
break
} else if i == len(c.commands)-1 {
c.commands = append(c.commands, *cmd)
}
}
}

func (c *Config) Run() {
Expand Down

0 comments on commit 930e376

Please sign in to comment.