1
0
Fork 0
mirror of https://github.com/Luzifer/go_helpers.git synced 2024-12-24 13:01:21 +00:00

Fix: Prevent panics when no arguments are given

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-05-19 14:15:02 +02:00
parent 9d7bd03948
commit 44c39c2599
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

View file

@ -50,8 +50,13 @@ func (c *Registry) Call(args []string) error {
c.Lock() c.Lock()
defer c.Unlock() defer c.Unlock()
cmdEntry := c.cmds[args[0]] cmd := "help"
if cmdEntry.Name != args[0] { if len(args) > 0 {
cmd = args[0]
}
cmdEntry := c.cmds[cmd]
if cmdEntry.Name != cmd {
c.help() c.help()
return ErrHelpCalled return ErrHelpCalled
} }