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:
parent
9d7bd03948
commit
44c39c2599
1 changed files with 7 additions and 2 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue