# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=xh
pkgver=0.24.0
pkgrel=0
pkgdesc="Yet another HTTPie clone"
url="https://github.com/ducaale/xh"
# s390x: fails to build terminal_size crate
arch="all !s390x"
license="MIT"
makedepends="
	cargo
	cargo-auditable
	oniguruma-dev
	openssl-dev
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/ducaale/xh/archive/v$pkgver/xh-$pkgver.tar.gz"
options="net" # fetch dependencies

# Link with system-provided oniguruma library (instead building from source
# and bundling).
export RUSTONIG_DYNAMIC_LIBONIG=1

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


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/

	ln -s xh "$pkgdir"/usr/bin/xhs

	install -Dm 644 doc/xh.1 "$pkgdir"/usr/share/man/man1/xh.1

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

sha512sums="
13bdfbc8598cc5f826dc6ae8df14ff3463061140dcc1b8db26dd8659d1d4f396ef5c1cd9b98e9a0779f91a0719140c67e9a623c0c49188979b20cc9b092614eb  xh-0.24.0.tar.gz
"
