# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=mcfly
pkgver=0.9.2
pkgrel=0
pkgdesc="Fly through your shell history"
url="https://github.com/cantino/mcfly"
arch="all"
license="MIT"
makedepends="cargo sqlite-dev cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/cantino/mcfly/archive/v$pkgver/mcfly-$pkgver.tar.gz
	reduce-config-features.patch
	"

_cargo_opts="--frozen --no-default-features"

# Reduce size of the mcfly binary.
export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"

prepare() {
	default_prepare

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

build() {
	cargo auditable build $_cargo_opts --release
}

check() {
	cargo test $_cargo_opts
}

package() {
	install -D -m755 target/release/$pkgname -t "$pkgdir"/usr/bin/

	install -Dm 644 mcfly.bash "$pkgdir"/usr/share/bash-completion/completions/mcfly
	install -Dm 644 mcfly.fish "$pkgdir"/usr/share/fish/vendor_completions.d/mcfly.fish
	install -Dm 644 mcfly.zsh "$pkgdir"/usr/share/zsh/site-functions/_mcfly
}

sha512sums="
ac787a0087dd5721685be1ef8f1f916d5e4d779530cea77cd7607589e841390356c3d0d4f89333a4a571262870bf90e06a989109f511491719814a07539d6211  mcfly-0.9.2.tar.gz
cdfb650af4ad87d14539449a46fbf8d8a04e09eb2ab279764420e054e3bb671e2dc462a101d9af6b35a5e609ff8467e23dd8c78a7749f43177bc741b71d4fde3  reduce-config-features.patch
"
