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

# Autogenerated by pycargoebuild 0.15.0

EAPI=8

CRATES="
	aho-corasick@1.1.3
	aligned@0.4.2
	anstream@0.6.18
	anstyle-parse@0.2.6
	anstyle-query@1.1.2
	anstyle-wincon@3.0.7
	anstyle@1.0.10
	anyhow@1.0.95
	as-slice@0.2.1
	autocfg@1.4.0
	bitflags@2.8.0
	cfg-if@1.0.0
	cfg_aliases@0.2.1
	clap@4.5.26
	clap_builder@4.5.26
	clap_derive@4.5.24
	clap_lex@0.7.4
	colorchoice@1.0.3
	crossterm@0.28.1
	crossterm_winapi@0.9.1
	cvt@0.1.2
	directories-next@2.0.0
	dirs-sys-next@0.1.2
	dns_common@0.2.1
	dns_common_derive@0.2.1
	dunce@1.0.5
	edit@0.1.5
	either@1.13.0
	equivalent@1.0.1
	errno@0.3.10
	etcetera@0.8.0
	fastrand@2.3.0
	fs_at@0.2.1
	getrandom@0.2.15
	hashbrown@0.15.2
	heck@0.5.0
	home@0.5.11
	indexmap@2.7.0
	is_terminal_polyfill@1.70.1
	itoa@1.0.14
	lazy_static@1.5.0
	libc@0.2.169
	libredox@0.1.3
	linux-raw-sys@0.4.15
	lock_api@0.4.12
	log@0.4.25
	matchers@0.1.0
	memchr@2.7.4
	mio@1.0.3
	nix@0.29.0
	normpath@1.3.0
	nu-ansi-term@0.46.0
	once_cell@1.20.2
	overload@0.1.1
	parking_lot@0.12.3
	parking_lot_core@0.9.10
	pin-project-lite@0.2.16
	proc-macro2@1.0.93
	quote@1.0.38
	redox_syscall@0.5.8
	redox_users@0.4.6
	regex-automata@0.1.10
	regex-automata@0.4.9
	regex-syntax@0.6.29
	regex-syntax@0.8.5
	regex@1.11.1
	remove_dir_all@1.0.0
	rustix@0.38.43
	ryu@1.0.18
	same-file@1.0.6
	scopeguard@1.2.0
	serde@1.0.217
	serde_derive@1.0.217
	serde_json@1.0.135
	serde_yaml@0.9.34+deprecated
	sharded-slab@0.1.7
	shellwords@1.1.0
	signal-hook-mio@0.2.4
	signal-hook-registry@1.4.2
	signal-hook@0.3.17
	smallvec@1.13.2
	stable_deref_trait@1.2.0
	strip-ansi-escapes@0.2.1
	strsim@0.11.1
	syn@1.0.109
	syn@2.0.96
	synstructure@0.12.6
	tempfile@3.15.0
	thiserror-impl@1.0.69
	thiserror-impl@2.0.11
	thiserror@1.0.69
	thiserror@2.0.11
	thread_local@1.1.8
	tracing-attributes@0.1.28
	tracing-core@0.1.33
	tracing-log@0.2.0
	tracing-subscriber@0.3.19
	tracing@0.1.41
	unicode-ident@1.0.14
	unicode-width@0.2.0
	unicode-xid@0.2.6
	unsafe-libyaml@0.2.11
	utf8parse@0.2.2
	valuable@0.1.1
	vte@0.14.1
	walkdir@2.5.0
	wasi@0.11.0+wasi-snapshot-preview1
	which@4.4.2
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.9
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-sys@0.48.0
	windows-sys@0.52.0
	windows-sys@0.59.0
	windows-targets@0.48.5
	windows-targets@0.52.6
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.48.5
	windows_aarch64_msvc@0.52.6
	windows_i686_gnu@0.48.5
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.48.5
	windows_i686_msvc@0.52.6
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.48.5
	windows_x86_64_msvc@0.52.6
"

inherit cargo edo

DESCRIPTION="An interactive cheatsheet tool for the command-line"
HOMEPAGE="https://github.com/denisidoro/navi"

if [[ "${PV}" = "9999" ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/denisidoro/navi.git"
else
	SRC_URI="
		https://github.com/denisidoro/navi/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
		${CARGO_CRATE_URIS}
	"

	KEYWORDS="~amd64"
fi

LICENSE="Apache-2.0"

# Dependent crate licenses
LICENSE+=" Apache-2.0 CC0-1.0 MIT Unicode-3.0"

SLOT="0"
IUSE="+command-execution +repo-management test"
REQUIRED_USE="test? ( command-execution )"
RESTRICT="!test? ( test )"

DOCS=(
	assets/
	docs/
	README.md
)

PATCHES=(
	"${FILESDIR}/${PN}-remove-bash-tests-needing-internet-connection.patch"
)

BDEPEND="test? ( app-misc/tmux app-shells/fzf )"
RDEPEND="|| ( app-shells/fzf app-misc/skim )"

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

src_prepare() {
	default
	sed -i "s|target/debug|$(cargo_target_dir)|" tests/run || die
}

src_configure() {
	local -a myfeatures

	use command-execution || myfeatures+=( "disable-command-execution" )
	use repo-management || myfeatures+=( "disable-repo-management" )

	cargo_src_configure
}

src_test() {
	mkdir "${T}/cheat-dir" || die
	touch "${T}/config-file" || die
	NAVI_CONFIG="${T}/config-file" NAVI_PATH="${T}/cheat-dir" cargo_src_test

	cargo_src_test
	edob -m "Running Bash tests" tests/run
}

src_install() {
	cargo_src_install
	einstalldocs
}
