# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Autogenerated by pycargoebuild 0.15.0

EAPI=8

inherit cargo shell-completion

DESCRIPTION="All-in-one LLM CLI Tool"
HOMEPAGE="https://github.com/sigoden/aichat"
SRC_URI="
	https://github.com/sigoden/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/kuprTheMan/contribute-deps/releases/download/${P}/${P}-crates.tar.xz
"

LICENSE="|| ( Apache-2.0 MIT )"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD Boost-1.0 CDLA-Permissive-2.0 ISC LGPL-3+ MIT MPL-2.0
	Unicode-3.0 ZLIB
"
SLOT="0"
KEYWORDS="~amd64"

RDEPEND="dev-libs/oniguruma:="
DEPEND="${RDEPEND}"
BDEPEND="virtual/pkgconfig"

src_configure() {
	# Link the system library instead of the copy bundled in onig_sys. Exported
	# for all phases: cargo_src_install rebuilds and would pick the bundled copy.
	export RUSTONIG_SYSTEM_LIBONIG=1
	cargo_src_configure
}

src_install() {
	cargo_src_install
	einstalldocs
	docinto examples
	dodoc config.example.yaml

	newbashcomp scripts/completions/aichat.bash aichat
	newzshcomp scripts/completions/aichat.zsh _aichat
	newfishcomp scripts/completions/aichat.fish aichat.fish

	# Shell integration (Alt-E turns a natural language prompt into a command).
	insinto /usr/share/aichat/shell-integration
	doins scripts/shell-integration/integration.{bash,fish,zsh}
}