From 7c3be83dd035ef2348896890902ca661c655e7b6 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Sun, 21 Aug 2022 19:04:57 +0200 Subject: [PATCH] Added ZSH completions --- APKBUILD | 13 +++++++++---- Makefile | 12 +++++------- zsh.completion | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 zsh.completion diff --git a/APKBUILD b/APKBUILD index 1622ac3..d36168f 100644 --- a/APKBUILD +++ b/APKBUILD @@ -2,14 +2,17 @@ # Maintainer: Marty Sluijtman pkgname=dice-roller pkgver=0.3 -pkgrel=4 +pkgrel=5 pkgdesc="A little D&D dice roller written in go" url="https://gitlab.com/EternalWanderer/dice-roller" arch="all" license="WTFPL-2.0" makedepends="go" -subpackages="$pkgname-doc" -source="https://alpine.voidcruiser.nl/src/dice-roller-$pkgver.tar.gz" +subpackages="$pkgname-doc + $pkgname-zsh-completion + " +source="https://alpine.voidcruiser.nl/src/dice-roller-$pkgver.tar.gz + zsh.completion" options="!check" build() { @@ -18,8 +21,10 @@ build() { package() { make install PREFIX=/usr DESTDIR="$pkgdir" + install -D -m 644 zsh.completion "$pkgdir"/usr/share/zsh/site-functions/_$pkgname } sha512sums=" -f7f7215622d25cc591829e1317e43e6f48a2133eec8c5004a708a1b58a3a06a736e3e187ce1c0d4b7b6eac59a60a7610289e8c4c4af543b5109f49242db7c600 dice-roller-0.3.tar.gz +ffd1ff18f245e0caa21756cb403f5eaef6249ceec18dcf6b2035c37ebe8b0538e008ad7b251582c2c126f11ae1a80aa0ce5c6c51305a0bc6389a6974820f7f6c dice-roller-0.3.tar.gz +c46bff230964323b7bcfdcecb502a390df74ea779ec0f6a7ce16253453a9cf81cb280573ede8c2597d7967430fec98ef4c40f0a1104671a367500c65d35eff53 zsh.completion " diff --git a/Makefile b/Makefile index 168cd6e..9c089b9 100644 --- a/Makefile +++ b/Makefile @@ -14,18 +14,16 @@ clean: dist: clean mkdir -p dice-roller-$(VERSION) - cp -R LICENSE Makefile README.md dice-roller.1 Colors Coin Dice $(SRC) dice-roller-$(VERSION) + cp -R zsh.completion LICENSE Makefile README.md dice-roller.1 Colors Coin Dice $(SRC) dice-roller-$(VERSION) tar -cf dice-roller-$(VERSION).tar dice-roller-$(VERSION) gzip dice-roller-$(VERSION).tar rm -rf dice-roller-$(VERSION) install: all - mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -f dice-roller $(DESTDIR)$(PREFIX)/bin - chmod 775 $(DESTDIR)$(PREFIX)/bin/dice-roller - mkdir -p $(DESTDIR)$(MANPREFIX)/man1 - cat dice-roller.1 > $(DESTDIR)$(MANPREFIX)/man1/dice-roller.1 - chmod 644 $(DESTDIR)$(MANPREFIX)/man1/dice-roller.1 + install -m 0775 -d $(DESTDIR)$(PREFIX)/bin + install -m 755 dice-roller $(DESTDIR)$(PREFIX)/bin + install -m 0775 -d $(DESTDIR)$(MANPREFIX)/man1 + install -m 644 dice-roller.1 $(DESTDIR)$(MANPREFIX)/man1 uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/dice-roller\ diff --git a/zsh.completion b/zsh.completion new file mode 100644 index 0000000..7873c3a --- /dev/null +++ b/zsh.completion @@ -0,0 +1,21 @@ +#compdef dice dice-roller + +arguments=( + '(--advantage --disadvantage --attacks)-a=[Roll a set rules multiple times]:(number of attacks)' + '(--advantage --disadvantage -a)--attacks=[Roll a set rules multiple times]:(number of attacks)' + + '(--advantage --disadvantage -throws)-c=-[Specify amount of dice to cast]:(number of dice)' + '(--advantage --disadvantage -c)--throws=-[Specify amount of dice to cast]:(number of dice)' + + '(--advantage --disadvantage --surfaces)-s=[Use to specify die surfaces]:(number of surfaces):(4 8 10 12 20 100)' + '(--advantage --disadvantage -s)--surfaces=[Use to specify die surfaces]:(number of surfaces):(4 8 10 12 20 100)' + + '(--modifier)-m=[Add modifier to result of rolls]:(number to add)' + '(-m)--modifier=[Add modifier to result of rolls]:(number to add)' + + '(--advantage -c --throws -a --attacks)--disadvantage[Roll 2d20 and take the lowest value]' + '(--disadvantage -c -a --throws --attacks)--advantage[Roll 2d20 and take the highest value]' + '(--disadvantage --advantage -a --attacks -s --surfaces -m --modifier)--coin[Toss coin, same as -s 2]' + +) +_arguments : $arguments