# Template file for 'mdcat'
pkgname=mdcat
version=2.3.1
revision=1
build_style=cargo
build_helper=qemu
hostmakedepends="pkg-config ruby-asciidoctor"
makedepends="openssl-devel"
depends="shared-mime-info"
checkdepends="shared-mime-info"
short_desc="Cat for markdown"
maintainer="cinerea0 <cinerea0@protonmail.com>"
license="MPL-2.0"
homepage="https://github.com/swsnr/mdcat"
changelog="https://raw.githubusercontent.com/swsnr/mdcat/main/CHANGELOG.md"
distfiles="https://github.com/swsnr/mdcat/archive/refs/tags/mdcat-${version}.tar.gz"
checksum=5dbee35f8b582bb3a023133fc564103e49d16f10a62e7a07ddf29a06fa2d48f5
make_check=ci-skip  # uses network tests which fail in CI

case "$XBPS_TARGET_MACHINE" in
	x86_64*|i686*|arm*|aarch64*) ;;
	*) broken="ftbfs in ring" ;;
esac

post_install() {
	ln -sf /usr/bin/mdcat "${DESTDIR}/usr/bin/mdless"
	# additional symlink to make completion generation work
	ln -sf "${DESTDIR}/usr/bin/mdcat" /usr/bin/mdcat

	for command in mdcat mdless; do
		for shell in bash fish zsh; do
			vtargetrun "${DESTDIR}/usr/bin/${command}" --completions "${shell}" \
				> "${command}.${shell}"
			vcompletion "${command}.${shell}" "${shell}" "${command}"
		done
	done

	asciidoctor -b manpage -a reproducible -o mdcat.1 mdcat.1.adoc
	vman mdcat.1
	ln -sf /usr/share/man/man1/mdcat.1 "${DESTDIR}/usr/share/man/man1/mdless.1"
}
