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

# Autogenerated by pycargoebuild 0.15.1

EAPI=8

MY_PN="${PN/-cli/}"

CRATES="
"

inherit cargo

DESCRIPTION="All-in-One Assistant for Claude Code, Codex, Gemini, OpenCode & OpenClaw"
HOMEPAGE="https://github.com/SaladDay/cc-switch-cli"
SRC_URI="
	https://github.com/SaladDay/${PN}/archive/refs/tags/v${PV}.tar.gz
		-> ${P}.tar.gz
	https://github.com/gentoo-zh-drafts/${PN}/releases/download/v${PV}/${P}-crates.tar.xz
	${CARGO_CRATE_URIS}
"
S="${WORKDIR}/${P}"

RUST_MIN_VER="1.92.0"

LICENSE="MIT"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD CC0-1.0 CDLA-Permissive-2.0 ISC MIT MPL-2.0
	Unicode-3.0 Unicode-DFS-2016 WTFPL-2 ZLIB
"
SLOT="0"
KEYWORDS="~amd64"
RESTRICT="test"

RDEPEND="app-arch/xz-utils"

# Rust does not use *FLAGS from make.conf; silence Portage warnings.
QA_FLAGS_IGNORED="usr/bin/${PN}"

src_prepare() {
	default

	rm src-tauri/rust-toolchain.toml || die
	sed -i '/^strip = "symbols"/d' src-tauri/Cargo.toml || die
}

src_configure() {
	cargo_src_configure --manifest-path "${S}/src-tauri/Cargo.toml" --bin ${MY_PN}
}

src_install() {
	newbin "src-tauri/$(cargo_target_dir)/${MY_PN}" ${PN}
	einstalldocs
}