# Copyright 2024-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"

inherit cargo shell-completion toolchain-funcs

DESCRIPTION="Julia installer and version multiplexer"
HOMEPAGE="https://github.com/JuliaLang/juliaup"
SRC_URI="
	https://github.com/JuliaLang/juliaup/archive/v${PV}/${P}.tar.gz
	https://github.com/yamader/juliaup/releases/download/v${PV}/${P}-crates.tar.xz
"

LICENSE="MIT"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD CDLA-Permissive-2.0 ISC MIT MPL-2.0 openssl
	Unicode-3.0
"
SLOT="0"
KEYWORDS="~amd64"

DOCS=( CHANGELOG.md README.md )

QA_FLAGS_IGNORED=".*"

src_test() {
	local mytestargs=(
		# The following tests require network access.
		--skip utils::channel_selection
		--skip utils::auto_install_valid_channel
		--skip utils::end_to_end_manifest_selection
		--skip utils::command_add
		--skip utils::api_getconfig1
		--skip utils::command_default
		--skip utils::command_gc
		--skip utils::command_initial_setup
		--skip utils::command_link
		--skip utils::alias
		--skip utils::command_override
		--skip utils::command_remove
		--skip utils::command_update
	)
	cargo_src_test -- "${mytestargs[@]}"
}

src_install() {
	cargo_src_install
	einstalldocs

	if ! tc-is-cross-compiler; then
		einfo "generating shell completion files"

		"${ED}"/usr/bin/juliaup completions bash > "${T}/${PN}" || die
		dobashcomp "${T}/${PN}"

		"${ED}"/usr/bin/juliaup completions zsh > "${T}/_${PN}" || die
		dozshcomp "${T}/_${PN}"

		"${ED}"/usr/bin/juliaup completions fish > "${T}/${PN}.fish" || die
		dofishcomp "${T}/${PN}.fish"
	else
		ewarn "Shell completion files not installed! Install them manually with '${PN} completions --help'"
	fi
}