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

# Auto-Generated by cargo-ebuild 0.5.4

EAPI=8

CRATES="
	Inflector-0.11.4
	aho-corasick-0.7.20
	aliasable-0.1.3
	anyhow-1.0.68
	askama-0.11.1
	askama_derive-0.11.2
	askama_escape-0.10.3
	askama_shared-0.12.2
	assert_cmd-2.0.7
	bincode-1.3.3
	bitflags-1.3.2
	bstr-1.1.0
	cc-1.0.78
	cfg-if-1.0.0
	clap-4.0.32
	clap_complete-4.0.7
	clap_complete_fig-4.0.2
	clap_derive-4.0.21
	clap_lex-0.3.0
	difflib-0.4.0
	dirs-4.0.0
	dirs-sys-0.3.7
	doc-comment-0.3.3
	dunce-1.0.3
	either-1.8.0
	errno-0.2.8
	errno-dragonfly-0.1.2
	fastrand-1.8.0
	fnv-1.0.7
	getrandom-0.2.8
	glob-0.3.1
	globset-0.4.10
	heck-0.4.0
	hermit-abi-0.2.6
	ignore-0.4.19
	instant-0.1.12
	io-lifetimes-1.0.3
	is-terminal-0.4.2
	itertools-0.10.5
	lazy_static-1.4.0
	libc-0.2.139
	linux-raw-sys-0.1.4
	log-0.4.17
	memchr-2.5.0
	mime-0.3.16
	mime_guess-2.0.4
	minimal-lexical-0.2.1
	nix-0.26.1
	nom-7.1.2
	once_cell-1.17.0
	os_str_bytes-6.4.1
	ouroboros-0.15.5
	ouroboros_macro-0.15.5
	predicates-2.1.5
	predicates-core-1.0.5
	predicates-tree-1.0.7
	proc-macro-error-1.0.4
	proc-macro-error-attr-1.0.4
	proc-macro2-1.0.49
	quote-1.0.23
	redox_syscall-0.2.16
	redox_users-0.4.3
	regex-1.7.0
	regex-automata-0.1.10
	regex-syntax-0.6.28
	remove_dir_all-0.5.3
	rstest-0.16.0
	rstest_macros-0.16.0
	rstest_reuse-0.4.0
	rustc_version-0.4.0
	rustix-0.36.6
	same-file-1.0.6
	semver-1.0.16
	serde-1.0.152
	serde_derive-1.0.152
	shell-words-1.1.0
	static_assertions-1.1.0
	strsim-0.10.0
	syn-1.0.107
	tempfile-3.3.0
	termcolor-1.1.3
	termtree-0.4.0
	thiserror-1.0.38
	thiserror-impl-1.0.38
	thread_local-1.1.4
	unicase-2.6.0
	unicode-ident-1.0.6
	version_check-0.9.4
	wait-timeout-0.2.0
	walkdir-2.3.2
	wasi-0.11.0+wasi-snapshot-preview1
	which-4.3.0
	winapi-0.3.9
	winapi-i686-pc-windows-gnu-0.4.0
	winapi-util-0.1.5
	winapi-x86_64-pc-windows-gnu-0.4.0
	windows-sys-0.42.0
	windows_aarch64_gnullvm-0.42.0
	windows_aarch64_msvc-0.42.0
	windows_i686_gnu-0.42.0
	windows_i686_msvc-0.42.0
	windows_x86_64_gnu-0.42.0
	windows_x86_64_gnullvm-0.42.0
	windows_x86_64_msvc-0.42.0
"

inherit cargo bash-completion-r1

DESCRIPTION="A smarter cd command for your terminal"
# Double check the homepage as the cargo_metadata crate
# does not provide this value so instead repository is used
HOMEPAGE="https://github.com/ajeetdsouza/zoxide"
SRC_URI="
	https://github.com/ajeetdsouza/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	$(cargo_crate_uris)
"

LICENSE="Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD BSD-2 CC0-1.0 MIT MIT-0 Unicode-DFS-2016 Unlicense"
SLOT="0"
KEYWORDS="~amd64"

DEPEND=""
RDEPEND="${DEPEND}"
BDEPEND=""

# rust does not use *FLAGS from make.conf, silence portage warning
# update with proper path to binaries this crate installs, omit leading /
QA_FLAGS_IGNORED="usr/bin/${PN}"

src_prepare() {
	sed -i 's:strip = true:strip = false:g' Cargo.toml || die
	default
}

src_install() {
	cargo_src_install

	doman man/man1/*
	dodoc README.md CHANGELOG.md

	newbashcomp contrib/completions/"${PN}".bash "${PN}"

	insinto /usr/share/zsh/site-functions
	doins contrib/completions/_"${PN}"

	insinto /usr/share/fish/vendor_completions.d
	doins contrib/completions/"${PN}".fish

	insinto /usr/share/"${PN}"
	doins init.fish
	doins zoxide.plugin.zsh
}