# Maintainer: Integral <integral@member.fsf.org>
# Contributor: iff <iff@ik.me>

pkgname=pay-respects
pkgver=0.8.8
pkgrel=1
pkgdesc="Terminal command suggestion, alternative to thefuck written in Rust with AI support"
arch=('x86_64' 'aarch64')
url="https://codeberg.org/iff/${pkgname}"
license=('AGPL-3.0-or-later')
makedepends=('cargo')
optdepends=('curl: for fetching AI suggestions')
replaces=('pay_respects')
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz")
sha256sums=('4be5b2602f939bf279db0f4428f0766e91e0fc53ea0f08b03a91d908bc173203')

prepare() {
	cd "${pkgname}/"
	cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
	cd "${pkgname}/"
	export CFLAGS+=" -ffat-lto-objects"
	export _DEF_PR_LIB="/usr/lib/${pkgname}/"
	cargo build --frozen --release --all-features --workspace
}

check() {
	cd "${pkgname}/"
	cargo test --frozen --all-features --workspace
}

package() {
	cd "${pkgname}/target/release"
	install -Dm755 "${pkgname}" -t "${pkgdir}/usr/bin/"
	install -Dm755 _${pkgname}-{module-100-runtime-rules,fallback-100-request-ai} -t "${pkgdir}/usr/lib/${pkgname}/"
}
