use updated opt package

This commit is contained in:
John Gebbie 2022-12-28 10:43:19 +00:00
parent 22dd3a62ff
commit 9f57e0ccc9
3 changed files with 14 additions and 13 deletions

View file

@ -196,12 +196,15 @@ func cutCmd(s, cmd string) (string, bool) {
func main() { func main() {
{ {
optset := opt.NewOptionSet() optset := opt.NewOptionSet()
help := func(bool) error {
optset.FlagFunc("h", func() error {
usage() usage()
os.Exit(0) os.Exit(0)
panic("unreachable") panic("unreachable")
} })
listKeys := func(bool) error { optset.Alias("h", "help")
optset.BoolFunc("list-keys", func(bool) error {
for i := 1; i < 249; i++ { for i := 1; i < 249; i++ {
for name, code := range linuxKeys { for name, code := range linuxKeys {
if code == i { if code == i {
@ -212,8 +215,9 @@ func main() {
} }
os.Exit(0) os.Exit(0)
panic("unreachable") panic("unreachable")
} })
listXKeys := func(bool) error {
optset.BoolFunc("list-x-keys", func(bool) error {
for i := 1; i < 249; i++ { for i := 1; i < 249; i++ {
for name, code := range xKeysNormal { for name, code := range xKeysNormal {
if code == i { if code == i {
@ -234,11 +238,8 @@ func main() {
} }
os.Exit(0) os.Exit(0)
panic("unreachable") 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:]) err := optset.Parse(true, os.Args[1:])
if err != nil { if err != nil {
fatal(err.Error()) fatal(err.Error())

2
go.mod
View file

@ -3,6 +3,6 @@ module git.sr.ht/~geb/dotool
go 1.19 go 1.19
require ( 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 github.com/bendahl/uinput v1.6.0
) )

4
go.sum
View file

@ -1,4 +1,4 @@
git.sr.ht/~geb/opt v0.0.0-20220627180516-52214b5b84a1 h1:bmje0IdPzrY5nX6fAx8KuHP5G8EP4XMedMFcrssfJXc= git.sr.ht/~geb/opt v0.0.0-20221207200434-dad26d091d71 h1:jh3Ite7R1ZvdLt6j52e4njO2SS/z5dWOLXllw7inalc=
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/go.mod h1:S6h1g8P7DyG7i7YIHZ5IpYbC6lzZB9DYIEl8PyXOmsg=
github.com/bendahl/uinput v1.6.0 h1:fM6r3OSC17rHh758mizKjSBuqi+XinhiGd4N3pWvZiI= github.com/bendahl/uinput v1.6.0 h1:fM6r3OSC17rHh758mizKjSBuqi+XinhiGd4N3pWvZiI=
github.com/bendahl/uinput v1.6.0/go.mod h1:Np7w3DINc9wB83p12fTAM3DPPhFnAKP0WTXRqCQJ6Z8= github.com/bendahl/uinput v1.6.0/go.mod h1:Np7w3DINc9wB83p12fTAM3DPPhFnAKP0WTXRqCQJ6Z8=