# Contributor: dai9ah <dai9ah@protonmail.com>
# Maintainer: dai9ah <dai9ah@protonmail.com>
pkgname=ddgr
pkgver=1.2
pkgrel=0
pkgdesc="DuckDuckGo from the terminal"
url="https://github.com/jarun/ddgr"
arch="noarch"
license="GPL-3.0-or-later"
depends="python3"
subpackages="$pkgname-doc
	$pkgname-bash-completion:bashcomp:noarch
	$pkgname-fish-completions:fishcomp:noarch
	$pkgname-zsh-completion:zshcomp:noarch
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/jarun/$pkgname/archive/v$pkgver.tar.gz"
builddir="$srcdir/$pkgname-$pkgver"

check() {
	cd "$builddir"
	./ddgr --help > /dev/null
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" PREFIX=/usr install
}

bashcomp() {
	pkgdesc="Bash completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	mkdir -p "$subpkgdir"/usr/share/bash-completion/completions/
	install -Dm644 "$builddir"/auto-completion/bash/* \
		"$subpkgdir"/usr/share/bash-completion/completions/
}

fishcomp() {
	pkgdesc="Fish completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel fish"

	mkdir -p "$subpkgdir"/usr/share/fish/completions/
	install -Dm644 "$builddir"/auto-completion/fish/* \
		"$subpkgdir"/usr/share/fish/completions/
}

zshcomp() {
	pkgdesc="Zsh completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	mkdir -p "$subpkgdir"/usr/share/zsh/site-functions
	install -Dm644 "$builddir"/auto-completion/zsh/* \
		"$subpkgdir"/usr/share/zsh/site-functions/

}

sha512sums="7e760f8e523f7ce2b5932756480440f5fb09419da832ef33141e7619a2216c470116e48dcfb33286c44d5c2ca0773b4030834d1d4946aaf9b9e48a67cd17d77f  ddgr-1.2.tar.gz"
