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

# Autogenerated by pycargoebuild 0.15.1

EAPI=8

RUST_MIN_VER="1.88.0"
CRATES=" "

inherit cargo edo shell-completion toolchain-funcs

DESCRIPTION="CLI tool for Forgejo"
HOMEPAGE="https://codeberg.org/forgejo-contrib/forgejo-cli"
SRC_URI="
	https://codeberg.org/forgejo-contrib/forgejo-cli/archive/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/gentoo-crate-dist/forgejo-cli/releases/download/v${PV}/forgejo-cli-${PV}-crates.tar.xz
"
S="${WORKDIR}/forgejo-cli"

LICENSE="|| ( Apache-2.0 MIT )"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD-2 BSD ISC MIT MPL-2.0 Unicode-3.0 Unicode-DFS-2016
	ZLIB
"
SLOT="0"
KEYWORDS="~amd64"

DOCS=( README.md )

src_install() {
	cargo_src_install

	local target="$(cargo_target_dir)"
	if ! tc-is-cross-compiler; then
		edo "${target}"/fj completion bash > "${T}"/fj.bash
		newbashcomp "${T}"/fj.bash fj
		edo "${target}"/fj completion zsh > "${T}"/fj.zsh
		newzshcomp "${T}"/fj.zsh _fj
		edo "${target}"/fj completion fish > "${T}"/fj.fish
		newfishcomp "${T}"/fj.fish fj.fish
	else
		ewarn "completion not installed because we're cross-compiling"
	fi
}
