diff --git a/go/go.mod b/go/go.mod index 7eb475b..405aff3 100644 --- a/go/go.mod +++ b/go/go.mod @@ -3,3 +3,5 @@ module github.com/shish/rosettaboy/go go 1.17 require github.com/veandco/go-sdl2 v0.4.24 // direct + +require github.com/spf13/pflag v1.0.5 // indirect diff --git a/go/go.sum b/go/go.sum index e830aaf..17c93b9 100644 --- a/go/go.sum +++ b/go/go.sum @@ -1,2 +1,4 @@ +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/veandco/go-sdl2 v0.4.24 h1:J+OCnPp0yfas4DAG13e3kIgC84mNxWGa3gpWYxrQQfI= github.com/veandco/go-sdl2 v0.4.24/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY= diff --git a/go/src/args.go b/go/src/args.go index c9b2c92..9b220d6 100644 --- a/go/src/args.go +++ b/go/src/args.go @@ -1,9 +1,12 @@ package main -import "flag" -import "runtime" -import "fmt" -import "os" +import ( + "fmt" + "os" + "runtime" + + flag "github.com/spf13/pflag" +) type Args struct { DebugCpu bool @@ -19,21 +22,26 @@ type Args struct { } func NewArgs() *Args { - var debug_cpu = flag.Bool("debug-cpu", false, "Debug CPU") - var debug_gpu = flag.Bool("debug-gpu", false, "Debug GPU") - var debug_apu = flag.Bool("debug-apu", false, "Debug APU") - var debug_ram = flag.Bool("debug-ram", false, "Debug RAM") - var headless = flag.Bool("headless", false, "No video") - var silent = flag.Bool("silent", false, "No audio") - var turbo = flag.Bool("turbo", false, "No sleep()") - var frames = flag.Int("frames", 0, "Exit after N frames") - var profile = flag.Int("profile", 0, "Exit after N seconds") - var version = flag.Bool("version", false, "Show build info") + var debug_cpu = flag.BoolP("debug-cpu", "c", false, "Debug CPU") + var debug_gpu = flag.BoolP("debug-gpu", "g", false, "Debug GPU") + var debug_apu = flag.BoolP("debug-apu", "a", false, "Debug APU") + var debug_ram = flag.BoolP("debug-ram", "r", false, "Debug RAM") + var headless = flag.BoolP("headless", "H", false, "No video") + var silent = flag.BoolP("silent", "S", false, "No audio") + var turbo = flag.BoolP("turbo", "t", false, "No sleep()") + var frames = flag.IntP("frames", "f", 0, "Exit after N frames") + var profile = flag.IntP("profile", "p", 0, "Exit after N seconds") + var version = flag.BoolP("version", "v", false, "Show build info") + var help = flag.BoolP("help", "h", false, "Show CLI help") flag.Parse() if *version { fmt.Println(runtime.Version()) os.Exit(0) } + if *help { + flag.Usage() + os.Exit(0) + } var rom = flag.Arg(0) return &Args{