# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=gum
pkgver=0.14.5
pkgrel=0
pkgdesc="Highly configurable utilities for writing interactive shell scripts"
url="https://github.com/charmbracelet/gum"
arch="all"
license="MIT"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
makedepends="go"
source="https://github.com/charmbracelet/gum/archive/v$pkgver/gum-$pkgver.tar.gz"
options="net" # downloading dependencies

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

build() {
	mkdir builddir

	go build -v \
		-trimpath \
		-ldflags "-X main.Version=$pkgver -extldflags \"$LDFLAGS\"" \
		-o builddir .

	./builddir/gum man > builddir/gum.1
	./builddir/gum completion bash > completion.bash
	./builddir/gum completion fish > completion.fish
	./builddir/gum completion zsh > completion.zsh
}

check() {
	./builddir/gum --version
}

package() {
	install -Dm755 builddir/gum "$pkgdir"/usr/bin/gum
	install -Dm644 builddir/gum.1 "$pkgdir"/usr/share/man/man1/gum.1
	install -Dm644 completion.bash "$pkgdir"/usr/share/bash-completion/completions/gum
	install -Dm644 completion.fish "$pkgdir"/usr/share/fish/vendor_completions.d/gum.fish
	install -Dm644 completion.zsh "$pkgdir"/usr/share/zsh/site-functions/_gum
}

sha512sums="
e37a934c22862c00eecb9128da70d5a73e92f78a3de2c9c64902842d84c2100fb8a412ecd2daf176b0bf2b557a56d70dba6f5660cf0359e906b8082cd473cc40  gum-0.14.5.tar.gz
"
