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

# Autogenerated by pycargoebuild 0.15.3

EAPI=8

CRATES="
	aho-corasick@1.1.4
	anstyle@1.0.14
	assert_fs@1.1.4
	aws-lc-rs@1.17.3
	aws-lc-sys@0.43.0
	base64@0.22.1
	bitflags@1.3.2
	bitflags@2.13.1
	bstr@1.13.0
	bytes@1.12.1
	castaway@0.2.4
	cc@1.3.0
	cfg-if@1.0.4
	cmake@0.1.58
	compact_str@0.9.1
	console@0.16.4
	crossbeam-deque@0.8.7
	crossbeam-epoch@0.9.20
	crossbeam-utils@0.8.22
	defmt-macros@1.1.1
	defmt-parser@1.0.0
	defmt@1.1.1
	difflib@0.4.0
	dunce@1.0.5
	dyn-clone@1.0.20
	encode_unicode@1.0.0
	errno@0.3.14
	fastrand@2.5.0
	find-msvc-tools@0.1.9
	fs_extra@1.3.0
	getrandom@0.2.17
	getrandom@0.4.3
	globset@0.4.19
	globwalk@0.9.1
	http@1.4.2
	httparse@1.10.1
	ignore@0.4.30
	insta@1.48.0
	itoa@1.0.18
	jiff-core@0.1.0
	jiff-static@0.2.34
	jiff-tzdb-platform@0.1.3
	jiff-tzdb@0.1.8
	jiff@0.2.34
	jobserver@0.1.35
	libc@0.2.186
	libmimalloc-sys@0.1.49
	linux-raw-sys@0.12.1
	log@0.4.33
	memchr@2.8.3
	mimalloc@0.1.52
	minreq@3.0.0
	once_cell@1.21.4
	percent-encoding@2.3.2
	pkg-config@0.3.33
	portable-atomic-util@0.2.7
	portable-atomic@1.14.0
	predicates-core@1.0.10
	predicates-tree@1.0.13
	predicates@3.1.4
	proc-macro2@1.0.107
	quote@1.0.47
	r-efi@6.0.0
	regex-automata@0.4.16
	regex-syntax@0.8.11
	ring@0.17.14
	rustc-hash@2.1.3
	rustix@1.1.4
	rustls-pki-types@1.15.0
	rustls-webpki@0.103.13
	rustls@0.23.42
	rustversion@1.0.23
	ryu@1.0.23
	same-file@1.0.6
	schemars@0.8.22
	schemars_derive@0.8.22
	serde@1.0.229
	serde_core@1.0.229
	serde_derive@1.0.229
	serde_derive_internals@0.29.1
	serde_json@1.0.151
	shlex@2.0.1
	similar@2.7.0
	smallvec@1.15.2
	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.119
	syn@3.0.2
	tempfile@3.27.0
	terminal_size@0.4.4
	termtree@0.5.1
	thiserror-impl@2.0.19
	thiserror@2.0.19
	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
	webpki-roots@1.0.9
	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
	zeroize@1.9.0
	zmij@1.0.23
"

LITELLM_REV="34561482ed092d78c296cab7999486022af5a938"

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
}