diff --git a/dotool.go b/dotool.go index ffc3382..67f4c30 100644 --- a/dotool.go +++ b/dotool.go @@ -196,12 +196,15 @@ func cutCmd(s, cmd string) (string, bool) { func main() { { optset := opt.NewOptionSet() - help := func(bool) error { + + optset.FlagFunc("h", func() error { usage() os.Exit(0) panic("unreachable") - } - listKeys := func(bool) error { + }) + optset.Alias("h", "help") + + optset.BoolFunc("list-keys", func(bool) error { for i := 1; i < 249; i++ { for name, code := range linuxKeys { if code == i { @@ -212,8 +215,9 @@ func main() { } os.Exit(0) panic("unreachable") - } - listXKeys := func(bool) error { + }) + + optset.BoolFunc("list-x-keys", func(bool) error { for i := 1; i < 249; i++ { for name, code := range xKeysNormal { if code == i { @@ -234,11 +238,8 @@ func main() { } os.Exit(0) panic("unreachable") - } - optset.BoolFunc("h", help) - optset.BoolFunc("help", help) - optset.BoolFunc("list-keys", listKeys) - optset.BoolFunc("list-x-keys", listXKeys) + }) + err := optset.Parse(true, os.Args[1:]) if err != nil { fatal(err.Error()) diff --git a/go.mod b/go.mod index 4445e69..20e37b7 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module git.sr.ht/~geb/dotool go 1.19 require ( - git.sr.ht/~geb/opt v0.0.0-20220627180516-52214b5b84a1 + git.sr.ht/~geb/opt v0.0.0-20221207200434-dad26d091d71 github.com/bendahl/uinput v1.6.0 ) diff --git a/go.sum b/go.sum index 06ca3c6..8ffbbac 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ -git.sr.ht/~geb/opt v0.0.0-20220627180516-52214b5b84a1 h1:bmje0IdPzrY5nX6fAx8KuHP5G8EP4XMedMFcrssfJXc= -git.sr.ht/~geb/opt v0.0.0-20220627180516-52214b5b84a1/go.mod h1:T5QFtG9s8i/kW5pDVCke6Mt2WmElJCIfTL1HMdpP7Rk= +git.sr.ht/~geb/opt v0.0.0-20221207200434-dad26d091d71 h1:jh3Ite7R1ZvdLt6j52e4njO2SS/z5dWOLXllw7inalc= +git.sr.ht/~geb/opt v0.0.0-20221207200434-dad26d091d71/go.mod h1:S6h1g8P7DyG7i7YIHZ5IpYbC6lzZB9DYIEl8PyXOmsg= github.com/bendahl/uinput v1.6.0 h1:fM6r3OSC17rHh758mizKjSBuqi+XinhiGd4N3pWvZiI= github.com/bendahl/uinput v1.6.0/go.mod h1:Np7w3DINc9wB83p12fTAM3DPPhFnAKP0WTXRqCQJ6Z8=