Panic on (incorrectly) passing subcommand flag to parent
Closed this issue · 3 comments
Sam-Izdat commented
While I'm trying to break odin any way I can and pestering you with the results, there's another issue similar to the last one I submitted.
If I have a program called "mycli" that has a sub-command called "dothing" which takes flag "-a" -- the following input by the user will cause a panic/rage-quit:
mycli -a dothing
[...snip...]
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x1 pc=0x809f9f0]
goroutine 16 [running]:
runtime.panic(0x817f500, 0x8267113)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xe9
github.com/jwaldrip/odin/cli.(*CLI).setFlagValue(0x1844e200, 0x0, 0x1840e008, 0x3, 0x3, 0x0, 0x0, 0x0)
/usr/share/go/src/github.com/jwaldrip/odin/cli/flag_parsing.go:160 +0x400
github.com/jwaldrip/odin/cli.(*CLI).setAliasValues(0x1844e200, 0x18432600, 0x1, 0x2, 0x1840e008, 0x3, 0x3, 0x0, 0x0, 0x0)
/usr/share/go/src/github.com/jwaldrip/odin/cli/flag_parsing.go:128 +0xaf
github.com/jwaldrip/odin/cli.(*CLI).parseFlags(0x1844e200, 0x1840e008, 0x3, 0x3, 0x0, 0x0, 0x0)
/usr/share/go/src/github.com/jwaldrip/odin/cli/flag_parsing.go:114 +0x1d2
github.com/jwaldrip/odin/cli.(*CLI).Start(0x1844e200, 0x1840e008, 0x3, 0x3)
/usr/share/go/src/github.com/jwaldrip/odin/cli/CLI.go:72 +0xb3
main.main()
/usr/share/go/src/mycli/mycli.go:XX +0xXX
goroutine 17 [runnable]:
runtime.MHeap_Scavenger()
/usr/local/go/src/pkg/runtime/mheap.c:507
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445
goroutine 18 [runnable]:
bgsweep()
/usr/local/go/src/pkg/runtime/mgc0.c:1976
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445
goroutine 19 [runnable]:
runfinq()
/usr/local/go/src/pkg/runtime/mgc0.c:2606
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445
edit - actually, it seems this happens regardless of the sub-command; maybe it's the result of something I'm doing wrong in the program flow?
jwaldrip commented
@Sam-Izdat can you share your code?
jwaldrip commented
@Sam-Izdat No worries, I already have a fix. Publishing now.