# Contributor: Joe Searle <joe@jsearle.net>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=pastel
pkgver=0.10.0
pkgrel=1
pkgdesc="Command-line tool to generate, analyze, convert and manipulate colors"
url="https://github.com/sharkdp/pastel"
arch="all"
license="Apache-2.0 OR MIT"
makedepends="rust cargo cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/sharkdp/pastel/archive/v$pkgver.tar.gz"
options="net" # fetch crates

prepare() {
	default_prepare

	cargo fetch --target="$CHOST" --locked
}

build() {
	export SHELL_COMPLETIONS_DIR="$builddir/completions"
	cargo auditable build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	local targetdir="target/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}"

	install -Dvm755 $targetdir/release/pastel -t "$pkgdir"/usr/bin/

	install -Dvm644 completions/pastel.bash \
		"$pkgdir"/usr/share/bash-completion/completions/pastel
	install -Dvm644 completions/_pastel \
		"$pkgdir"/usr/share/zsh/site-functions/_pastel
	install -Dvm644 completions/pastel.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/pastel.fish
}

sha512sums="
1e79d964564346219e6170b37dba19cdf85b7245cd4e6640860339606da3237bec1cc1c67a909e03b979b168e72ecf6490a681bb3562302a9227d1a9bfc5e9f2  pastel-0.10.0.tar.gz
"
