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

# Autogenerated by pycargoebuild 0.16.0

EAPI=8

CRATES="
	adler2@2.0.1
	aho-corasick@1.1.5
	anstyle@1.0.14
	assert_fs@1.1.4
	aws-lc-rs@1.18.1
	aws-lc-sys@0.45.0
	base64@0.23.1
	bitflags@1.3.2
	bitflags@2.13.2
	bstr@1.13.1
	bytes@1.12.1
	castaway@0.2.4
	cc@1.6.0
	cfg-if@1.0.5
	cmake@0.1.58
	compact_str@0.10.0
	console@0.16.6
	crc32fast@1.5.2
	crossbeam-deque@0.8.8
	crossbeam-epoch@0.9.21
	crossbeam-utils@0.8.23
	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
	equivalent@1.0.2
	errno@0.3.14
	fastrand@2.5.0
	find-msvc-tools@0.1.14
	flate2@1.1.10
	fs_extra@1.3.0
	getrandom@0.2.17
	getrandom@0.4.3
	globset@0.4.20
	globwalk@0.9.1
	hashbrown@0.17.1
	http@1.5.0
	httparse@1.10.1
	ignore@0.4.33
	indexmap@2.14.2
	insta@1.49.0
	itoa@1.0.18
	jiff-core@0.1.1
	jiff-static@0.2.38
	jiff-tzdb-platform@0.1.3
	jiff-tzdb@0.1.9
	jiff@0.2.38
	jobserver@0.1.35
	libc@0.2.190
	libmimalloc-sys@0.1.49
	linux-raw-sys@0.12.1
	log@0.4.34
	memchr@2.8.3
	mimalloc@0.1.52
	miniz_oxide@0.9.1
	minreq@3.0.0
	once_cell@1.21.4
	percent-encoding@2.3.2
	pkg-config@0.3.34
	portable-atomic-util@0.2.8
	portable-atomic@1.15.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.18
	regex-syntax@0.8.11
	ring@0.17.14
	rustc-hash@2.1.3
	rustix@1.1.5
	rustls-pki-types@1.15.1
	rustls-webpki@0.103.15
	rustls@0.23.45
	rustversion@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
	serde_spanned@1.1.2
	shlex@2.0.1
	simd-adler32@0.3.10
	similar@2.7.0
	smallvec@1.16.2
	sqlite3-src@0.7.1
	sqlite3-sys@0.18.2
	sqlite@0.37.4
	static_assertions@1.1.0
	subtle@2.6.1
	syn@2.0.119
	syn@3.0.6
	tempfile@3.27.0
	terminal_size@0.4.4
	termtree@0.5.1
	thiserror-impl@2.0.21
	thiserror@2.0.21
	toml@1.1.8+spec-1.1.0
	toml_datetime@1.1.2+spec-1.1.0
	toml_parser@1.1.5+spec-1.1.0
	toml_writer@1.1.3+spec-1.1.0
	unicode-ident@1.0.26
	unicode-width@0.2.2
	untrusted@0.9.0
	ureq-proto@0.6.4
	ureq@3.4.2
	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
	winnow@1.0.4
	zeroize@1.9.1
	zlib-rs@0.6.8
	zmij@1.0.23
"

LITELLM_REV="145c53bedfac48f724dde16d281450c3aaf697c0"

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 -> \
		litellm-pricing-${LITELLM_REV}.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}/litellm-pricing-${LITELLM_REV}.json"
	default
}