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

# Autogenerated by pycargoebuild 0.15.1

EAPI=8

CRATES="
	aho-corasick@1.1.4
	anstyle@1.0.14
	assert_fs@1.1.3
	aws-lc-rs@1.17.0
	aws-lc-sys@0.41.0
	base64@0.22.1
	bitflags@2.11.1
	bstr@1.12.1
	bytes@1.11.1
	castaway@0.2.4
	cc@1.2.62
	cfg-if@1.0.4
	cmake@0.1.58
	compact_str@0.9.0
	console@0.16.3
	crossbeam-deque@0.8.6
	crossbeam-epoch@0.9.18
	crossbeam-utils@0.8.21
	difflib@0.4.0
	doc-comment@0.3.4
	dunce@1.0.5
	dyn-clone@1.0.20
	encode_unicode@1.0.0
	errno@0.3.14
	fastrand@2.4.1
	find-msvc-tools@0.1.9
	fs_extra@1.3.0
	getrandom@0.2.17
	getrandom@0.3.4
	globset@0.4.18
	globwalk@0.9.1
	http@1.4.0
	httparse@1.10.1
	ignore@0.4.25
	insta@1.47.2
	itoa@1.0.18
	jiff-static@0.2.24
	jiff@0.2.24
	jobserver@0.1.34
	libc@0.2.186
	libmimalloc-sys@0.1.47
	linux-raw-sys@0.12.1
	log@0.4.29
	memchr@2.8.0
	mimalloc@0.1.50
	minreq@3.0.0-rc.1
	once_cell@1.21.4
	percent-encoding@2.3.2
	phf@0.13.1
	phf_generator@0.13.1
	phf_macros@0.13.1
	phf_shared@0.13.1
	pkg-config@0.3.33
	portable-atomic-util@0.2.7
	portable-atomic@1.13.1
	predicates-core@1.0.10
	predicates-tree@1.0.13
	predicates@3.1.4
	proc-macro2@1.0.106
	quote@1.0.45
	r-efi@5.3.0
	regex-automata@0.4.14
	regex-syntax@0.8.10
	ring@0.17.14
	rustc-hash@2.1.2
	rustix@1.1.4
	rustls-pki-types@1.14.1
	rustls-webpki@0.103.13
	rustls@0.23.40
	rustversion@1.0.22
	ryu@1.0.23
	same-file@1.0.6
	schemars@0.8.22
	schemars_derive@0.8.22
	serde@1.0.228
	serde_core@1.0.228
	serde_derive@1.0.228
	serde_derive_internals@0.29.1
	serde_json@1.0.149
	shlex@1.3.0
	similar@2.7.0
	siphasher@1.0.3
	smallvec@1.15.1
	sqlite3-src@0.7.0
	sqlite3-sys@0.18.0
	sqlite@0.37.0
	static_assertions@1.1.0
	subtle@2.6.1
	syn@2.0.117
	tempfile@3.27.0
	terminal_size@0.4.4
	termtree@0.5.1
	unicode-ident@1.0.24
	unicode-width@0.2.2
	untrusted@0.9.0
	ureq-proto@0.6.0
	ureq@3.3.0
	utf8-zero@0.8.1
	walkdir@2.5.0
	wasi@0.11.1+wasi-snapshot-preview1
	wasip2@1.0.3+wasi-0.2.9
	webpki-roots@1.0.7
	winapi-util@0.1.11
	windows-link@0.2.1
	windows-sys@0.52.0
	windows-sys@0.61.2
	windows-targets@0.52.6
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.52.6
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.52.6
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.52.6
	wit-bindgen@0.57.1
	zeroize@1.8.2
	zmij@1.0.21
"

LITELLM_REV="e59e34bed3670a6894d43129c2af16af28057d03"

inherit cargo
DESCRIPTION="Usage analysis tool for Claude Code token usage and costs"
HOMEPAGE="https://github.com/ryoppippi/ccusage https://ccusage.com/"
SRC_URI="
	https://github.com/ryoppippi/ccusage/archive/refs/tags/v${PV}.tar.gz -> ${P}.tgz
	${CARGO_CRATE_URIS}
	https://raw.githubusercontent.com/BerriAI/litellm/${LITELLM_REV}/model_prices_and_context_window.json -> \
		ccusage-${PV}-litellm-pricing.json
"

S="${WORKDIR}/${P}/rust/crates/ccusage"

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

src_prepare() {
	default

	local flake_rev
	flake_rev=$(awk -F'"' '/"litellm":/{f=1} f && /"rev":/{print $4; exit}' \
			"${WORKDIR}/${P}/flake.lock")
	if [[ ${flake_rev} != ${LITELLM_REV} ]]; then
		die "litellm rev mismatch: flake.lock has ${flake_rev}, ebuild has ${LITELLM_REV}."
	fi
}

src_configure() {
	export CCUSAGE_PRICING_JSON_PATH="${DISTDIR}/ccusage-${PV}-litellm-pricing.json"
	default
}