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

EAPI=8

if [[ ${PV} != *9999 ]]; then
	CRATES="
	addr2line@0.24.2
	adler2@2.0.1
	ahash@0.8.12
	aho-corasick@1.1.3
	allocator-api2@0.2.21
	anstream@0.6.19
	anstyle-parse@0.2.7
	anstyle-query@1.1.3
	anstyle-wincon@3.0.9
	anstyle@1.0.11
	anyhow@1.0.98
	arboard@3.6.0
	async-trait@0.1.88
	autocfg@1.5.0
	backtrace@0.3.75
	base64@0.22.1
	bitflags@1.3.2
	bitflags@2.9.1
	bytemuck@1.23.1
	byteorder-lite@0.1.0
	bytes@1.10.1
	cc@1.2.29
	cfg-if@1.0.1
	chrono@0.4.41
	chumsky@0.9.3
	clap@4.5.41
	clap_builder@4.5.41
	clap_derive@4.5.41
	clap_lex@0.7.5
	clipboard-win@5.4.0
	colorchoice@1.0.4
	convert_case@0.7.1
	crc32fast@1.5.0
	crossbeam-deque@0.8.6
	crossbeam-epoch@0.9.18
	crossbeam-skiplist@0.1.3
	crossbeam-utils@0.8.21
	crossterm@0.29.0
	crossterm_winapi@0.9.1
	darling@0.20.11
	darling_core@0.20.11
	darling_macro@0.20.11
	derive_builder@0.20.2
	derive_builder_core@0.20.2
	derive_builder_macro@0.20.2
	derive_more-impl@2.0.1
	derive_more@2.0.1
	dirs-sys@0.5.0
	dirs@6.0.0
	dispatch2@0.3.0
	document-features@0.2.11
	downcast-rs@1.2.1
	duration-string@0.5.2
	dyn-clone@1.0.19
	either@1.15.0
	equivalent@1.0.2
	errno@0.3.13
	error-code@3.3.2
	fastrand@2.3.0
	fdeflate@0.3.7
	filedescriptor@0.8.3
	fixedbitset@0.4.2
	flate2@1.1.2
	fnv@1.0.7
	futures-channel@0.3.31
	futures-core@0.3.31
	futures-executor@0.3.31
	futures-io@0.3.31
	futures-macro@0.3.31
	futures-sink@0.3.31
	futures-task@0.3.31
	futures-util@0.3.31
	futures@0.3.31
	gethostname@0.4.3
	getrandom@0.2.16
	getrandom@0.3.3
	gimli@0.31.1
	hashbrown@0.14.5
	hashbrown@0.15.4
	heck@0.5.0
	hifijson@0.2.2
	ident_case@1.0.1
	image@0.25.6
	indexmap@2.10.0
	io-uring@0.7.8
	is_terminal_polyfill@1.70.1
	itoa@1.0.15
	jaq-core@1.5.1
	jaq-interpret@1.5.0
	jaq-parse@1.0.3
	jaq-std@1.6.0
	jaq-syn@1.6.0
	jpeg-decoder@0.3.2
	libc@0.2.174
	libm@0.2.15
	libredox@0.1.4
	linux-raw-sys@0.4.15
	linux-raw-sys@0.9.4
	litrs@0.4.1
	lock_api@0.4.13
	log@0.4.27
	memchr@2.7.5
	minimal-lexical@0.2.1
	miniz_oxide@0.8.9
	mio@1.0.4
	nom@7.1.3
	num-traits@0.2.19
	objc2-app-kit@0.3.1
	objc2-core-foundation@0.3.1
	objc2-core-graphics@0.3.1
	objc2-encode@4.1.0
	objc2-foundation@0.3.1
	objc2-io-surface@0.3.1
	objc2@0.6.1
	object@0.36.7
	once_cell@1.21.3
	once_cell_polyfill@1.70.1
	option-ext@0.2.0
	os_pipe@1.2.2
	parking_lot@0.12.4
	parking_lot_core@0.9.11
	percent-encoding@2.3.1
	petgraph@0.6.5
	pin-project-lite@0.2.16
	pin-utils@0.1.0
	pkg-config@0.3.32
	png@0.17.16
	proc-macro2@1.0.95
	promkit-core@0.2.0
	promkit-widgets@0.2.0
	quick-xml@0.37.5
	quote@1.0.40
	r-efi@5.3.0
	rayon-core@1.12.1
	rayon@1.10.0
	redox_syscall@0.5.13
	redox_users@0.5.0
	regex-automata@0.4.9
	regex-syntax@0.8.5
	regex@1.11.1
	rustc-demangle@0.1.25
	rustix@0.38.44
	rustix@1.0.8
	ryu@1.0.20
	scopeguard@1.2.0
	serde@1.0.219
	serde_derive@1.0.219
	serde_json@1.0.140
	serde_spanned@1.0.0
	shlex@1.3.0
	signal-hook-mio@0.2.4
	signal-hook-registry@1.4.5
	signal-hook@0.3.18
	simd-adler32@0.3.7
	slab@0.4.10
	smallvec@1.15.1
	socket2@0.5.10
	strsim@0.11.1
	syn@2.0.104
	tempfile@3.20.0
	thiserror-impl@1.0.69
	thiserror-impl@2.0.12
	thiserror@1.0.69
	thiserror@2.0.12
	tiff@0.9.1
	tokio-macros@2.5.0
	tokio-stream@0.1.17
	tokio@1.46.1
	toml@0.9.2
	toml_datetime@0.7.0
	toml_parser@1.0.1
	toml_writer@1.0.2
	tree_magic_mini@3.1.6
	unicode-ident@1.0.18
	unicode-segmentation@1.12.0
	unicode-width@0.2.1
	urlencoding@2.1.3
	utf8parse@0.2.2
	version_check@0.9.5
	wasi@0.11.1+wasi-snapshot-preview1
	wasi@0.14.2+wasi-0.2.4
	wayland-backend@0.3.10
	wayland-client@0.31.10
	wayland-protocols-wlr@0.3.8
	wayland-protocols@0.32.8
	wayland-scanner@0.31.6
	wayland-sys@0.31.6
	weezl@0.1.10
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-sys@0.52.0
	windows-sys@0.59.0
	windows-sys@0.60.2
	windows-targets@0.48.5
	windows-targets@0.52.6
	windows-targets@0.53.2
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_gnullvm@0.53.0
	windows_aarch64_msvc@0.48.5
	windows_aarch64_msvc@0.52.6
	windows_aarch64_msvc@0.53.0
	windows_i686_gnu@0.48.5
	windows_i686_gnu@0.52.6
	windows_i686_gnu@0.53.0
	windows_i686_gnullvm@0.52.6
	windows_i686_gnullvm@0.53.0
	windows_i686_msvc@0.48.5
	windows_i686_msvc@0.52.6
	windows_i686_msvc@0.53.0
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnu@0.53.0
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_gnullvm@0.53.0
	windows_x86_64_msvc@0.48.5
	windows_x86_64_msvc@0.52.6
	windows_x86_64_msvc@0.53.0
	winnow@0.7.12
	wit-bindgen-rt@0.39.0
	wl-clipboard-rs@0.9.2
	x11rb-protocol@0.13.1
	x11rb@0.13.1
	zerocopy-derive@0.8.26
	zerocopy@0.8.26
	"
fi

inherit cargo

DESCRIPTION="JSON navigator and interactive filter leveraging jq"
HOMEPAGE="https://github.com/ynqa/jnv"
GITHUB_USER=ynqa
GITHUB_REPO=${PN}

if [[ ${PV} == *9999 ]]; then
    EGIT_REPO_URI="https://github.com/${GITHUB_USER}/${GITHUB_REPO}"
    inherit git-r3
else
    [[ ${PV} == *_pre???????? ]] && COMMIT=""

    SRC_URI="https://github.com/${GITHUB_USER}/${GITHUB_REPO}/archive/${COMMIT:-v${PV}}.tar.gz -> ${P}.tar.gz
        ${CARGO_CRATE_URIS}"
    S="${WORKDIR}/${PN}-${COMMIT:-${PV}}"
    KEYWORDS="amd64 x86 arm arm64 ~ppc64 ~riscv"
fi

LICENSE="MIT"
# Dependent crate licenses
LICENSE+=" Apache-2.0 Boost-1.0 MIT MPL-2.0 Unicode-3.0"
SLOT="0"
RESTRICT="mirror"

QA_FLAGS_IGNORED="usr/bin/${PN}"

src_unpack() {
    if [[ ${PV} == *9999* ]]; then
        git-r3_src_unpack
        cargo_live_src_unpack
    else
        cargo_src_unpack
    fi
}

src_compile() {
    cargo_src_compile --bin=${PN}
}

src_install() {
    cargo_src_install --bin=${PN}
}