# Copyright 2022-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit optfeature

DESCRIPTION="Bash scripts that integrate bat with various command line tools."
HOMEPAGE="https://github.com/eth-p/bat-extras"
if [[ ${PV} == 9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/eth-p/bat-extras.git"
else
	KEYWORDS="~amd64"
	SRC_URI="https://github.com/eth-p/bat-extras/archive/v${PV}.tar.gz -> ${P}.tar.gz"
	# Requires test dir to be a git repo
	RESTRICT="test"
fi

LICENSE="MIT"
SLOT="0"

BDEPEND="
	app-shells/bash
	sys-apps/bat
	dev-util/sh
"
RDEPEND="
	${BDEPEND}
	app-admin/entr
	app-shells/fzf
	dev-python/black
	dev-util/git-delta
	dev-vcs/git
	sys-apps/eza
	sys-apps/ripgrep
	llvm-core/clang[extra(+)]
	sys-libs/ncurses
"

src_compile() {
	./build.sh --compress --minify=all --manuals --no-verify || die "build failed"
}

src_test() {
	./test.sh || die "test failed"
}

src_install() {
	dobin bin/*
	doman man/*
}

pkg_postinst() {
	einfo "To enable additional code formatting for 'prettybat' script, ensure"
	einfo "'net-libs/nodejs' is installed in your system, and use 'npm' to install"
	einfo "'prettier' (npm i -g prettier). Once 'prettier' is properly installed in"
	einfo "your system, remerge this package."

	optfeature "Rust code formatting" dev-lang/rust[rustfmt] dev-lang/rust-bin[rustfmt]
}
