# Contributor: omni <omni+alpine@hack.org>
# Maintainer: omni <omni+alpine@hack.org>
pkgname=godap
pkgver=2.7.5
pkgrel=0
pkgdesc="A complete TUI for LDAP"
url="https://github.com/Macmod/godap"
license="MIT"
arch="all"
makedepends="go"
subpackages="$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
options="net"
source="$pkgname-$pkgver.tar.gz::https://github.com/Macmod/godap/archive/refs/tags/v$pkgver.tar.gz"

export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build \
		-ldflags="-linkmode=external -extldflags \"$LDFLAGS\"" \
		-v .

	local shell; for shell in bash fish powershell zsh; do
		./godap completion "$shell" > "$pkgname"_"$shell"
	done
}

check() {
	# no upstream tests
	./godap version
}

package() {
	install -Dm0755 "$pkgname" -t "$pkgdir"/usr/bin

	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
	install -Dm644 README.md "$pkgdir"/usr/share/doc/"$pkgname"/README.md

	install -Dm644 "$pkgname"_bash "$pkgdir"/usr/share/bash-completion/completions/"$pkgname"
	install -Dm644 "$pkgname"_fish "$pkgdir"/usr/share/fish/vendor_completions.d/"$pkgname".fish
	install -Dm644 "$pkgname"_zsh "$pkgdir"/usr/share/zsh/site-functions/_"$pkgname"
}

sha512sums="
b89c23d4b61523c4e18e1927f68852e249cd096a6dfc30e4df13ebf866cb9bd4e1738af8f45d0c65bc28fb11b23d7e7f05386057540a6774f30c1564f1248f2a  godap-2.7.5.tar.gz
"
