# Contributor: Andrej Kolchin <KAAtheWise@protonmail.com>
# Maintainer: Andrej Kolchin <KAAtheWise@protonmail.com>
pkgname=carapace
pkgver=1.0.7
pkgrel=6
pkgdesc="Multi-shell multi-command argument completer"
url="https://carapace.sh/"
arch="all"
license="MIT"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/rsteube/carapace-bin/archive/v$pkgver.tar.gz"
# fixes the tar archive unpacking to carapace-bin-$pkgver
_pkgname=carapace-bin
builddir="$srcdir/$_pkgname-$pkgver"

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

build() {
	go generate ./cmd/carapace/...
	go build -tags release ./cmd/carapace
}

check() {
	# The three lone tests in the repository.
	go test \
		./cmd/carapace/... \
		./pkg/actions/tools/pandoc \
		./pkg/actions/env
}

package() {
	install -Dm755 carapace -t "$pkgdir"/usr/bin
}

sha512sums="
2d83d1d1a6241bf5bfe114d06cfe52703bf9c94d26141cdca0bc7767e5f8144b904c89e1aba910d1fa86c9cbce972e7968737c40dc9fd5471cf1b7777c453140  carapace-1.0.7.tar.gz
"
