marcosnils / bin

Effortless binary manager
MIT License
685 stars 46 forks source link

fix crash for invokation without args #159

Closed matheuscscp closed 1 year ago

matheuscscp commented 1 year ago

hi @marcosnils, I just noticed that my patch is making bin crash when invoked without any arguments (should print help instead):

➜  bin git:(hotfix) bin
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/marcosnils/bin/cmd.defaultCommand(0xc000004900, {0xc000022050?, 0x0, 0xc000012700?})
    /home/marcos/Projects/bin/cmd/root.go:103 +0x1f2
github.com/marcosnils/bin/cmd.(*rootCmd).Execute(0xc0000112c0, {0xc000022050, 0x0, 0xb4f060?})
    /home/marcos/Projects/bin/cmd/root.go:31 +0x71
github.com/marcosnils/bin/cmd.Execute({0xc00007a230, 0x6b}, 0xdf2220?, {0xc000022050, 0x0, 0x0})
    /home/marcos/Projects/bin/cmd/root.go:25 +0xbb
main.main()
    /home/marcos/Projects/bin/main.go:21 +0x97
➜  bin git:(hotfix) 
mbevc1 commented 1 year ago

@marcosnils can you also cut a release including this fix please?

marcosnils commented 1 year ago

done

mbevc1 commented 1 year ago

Cheers :+1: :rocket: