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

# Auto-Generated by cargo-ebuild 0.5.4-r1

EAPI=8

CRATES="
	ahash@0.8.3
	aho-corasick@0.7.20
	aho-corasick@1.0.1
	anstream@0.3.1
	anstyle@1.0.0
	anstyle-parse@0.2.0
	anstyle-query@1.0.0
	anstyle-wincon@1.0.1
	anyhow@1.0.70
	async-recursion@1.0.4
	async-stream@0.3.5
	async-stream-impl@0.3.5
	async-trait@0.1.68
	atomic-take@1.1.0
	autocfg@1.1.0
	bitflags@1.3.2
	bitflags@2.4.2
	block-buffer@0.10.4
	bstr@0.2.17
	bstr@1.4.0
	bumpalo@3.15.0
	bytes@1.4.0
	cc@1.0.79
	cfg-if@1.0.0
	clap@4.2.5
	clap_builder@4.2.5
	clap_complete@4.2.1
	clap_derive@4.2.0
	clap_lex@0.4.1
	clearscreen@1.0.11
	colorchoice@1.0.0
	command-group@1.0.8
	const-random@0.1.15
	const-random-macro@0.1.15
	cpufeatures@0.2.7
	crossbeam-channel@0.5.8
	crossbeam-utils@0.8.15
	crossterm@0.25.0
	crossterm_winapi@0.9.0
	cruet@0.14.0
	crunchy@0.2.2
	crypto-common@0.1.6
	deunicode@1.4.3
	diff@0.1.13
	difflib@0.4.0
	digest@0.10.6
	dirs@4.0.0
	dirs-sys@0.3.7
	downcast@0.11.0
	dunce@1.0.4
	either@1.8.1
	enquote@1.1.0
	equivalent@1.0.1
	errno@0.3.1
	errno-dragonfly@0.1.2
	filetime@0.2.21
	float-cmp@0.9.0
	fnv@1.0.7
	fragile@2.0.0
	fsevent-sys@4.1.0
	futures@0.3.28
	futures-channel@0.3.28
	futures-core@0.3.28
	futures-executor@0.3.28
	futures-io@0.3.28
	futures-macro@0.3.28
	futures-sink@0.3.28
	futures-task@0.3.28
	futures-util@0.3.28
	generic-array@0.14.7
	getrandom@0.2.9
	git-config@0.2.1
	git-features@0.20.0
	git-hash@0.9.11
	globset@0.4.10
	handlebars@5.1.0
	handlebars_misc_helpers@0.15.0
	hashbrown@0.14.3
	heck@0.4.1
	hermit-abi@0.2.6
	hermit-abi@0.3.1
	hex@0.4.3
	hostname@0.3.1
	ignore@0.4.20
	indexmap@2.2.3
	inotify@0.9.6
	inotify-sys@0.1.5
	instant@0.1.12
	io-lifetimes@1.0.10
	is-terminal@0.4.7
	itertools@0.10.5
	itoa@1.0.6
	jmespath@0.3.0
	kqueue@1.0.7
	kqueue-sys@1.0.3
	lazy_static@1.4.0
	libc@0.2.142
	linux-raw-sys@0.3.5
	lock_api@0.4.9
	log@0.4.17
	maplit@1.0.2
	match_cfg@0.1.0
	memchr@2.5.0
	memoffset@0.6.5
	meval@0.2.0
	miette@3.3.0
	miette-derive@3.3.0
	minimal-lexical@0.2.1
	mio@0.8.6
	mockall@0.11.4
	mockall_derive@0.11.4
	nix@0.22.3
	nix@0.24.3
	nom@1.2.4
	nom@5.1.3
	nom@7.1.3
	normalize-line-endings@0.3.0
	notify@5.0.0-pre.14
	num-traits@0.2.15
	num_cpus@1.15.0
	num_threads@0.1.6
	once_cell@1.17.1
	parking_lot@0.12.1
	parking_lot_core@0.9.7
	pest@2.6.0
	pest_derive@2.6.0
	pest_generator@2.6.0
	pest_meta@2.6.0
	phf@0.11.1
	phf_codegen@0.11.1
	phf_generator@0.11.1
	phf_shared@0.11.1
	pin-project-lite@0.2.9
	pin-utils@0.1.0
	predicates@2.1.5
	predicates-core@1.0.6
	predicates-tree@1.0.9
	proc-macro-hack@0.5.20+deprecated
	proc-macro2@1.0.56
	pwd@1.4.0
	quick-error@2.0.1
	quote@1.0.26
	rand@0.8.5
	rand_core@0.6.4
	redox_syscall@0.2.16
	redox_users@0.4.3
	regex@1.8.1
	regex-syntax@0.7.1
	rhai@1.17.1
	rhai_codegen@2.0.0
	rustix@0.37.15
	ryu@1.0.13
	same-file@1.0.6
	scopeguard@1.1.0
	serde@1.0.160
	serde_derive@1.0.160
	serde_json@1.0.96
	serde_spanned@0.6.5
	serde_yaml@0.9.25
	sha2@0.10.6
	shellexpand@2.1.2
	signal-hook@0.3.15
	signal-hook-mio@0.2.3
	signal-hook-registry@1.4.1
	simplelog@0.12.1
	siphasher@0.3.10
	slab@0.4.8
	slug@0.1.5
	smallvec@1.10.0
	smartstring@1.0.1
	static_assertions@1.1.0
	strsim@0.10.0
	syn@1.0.109
	syn@2.0.15
	termcolor@1.1.3
	terminfo@0.7.5
	termtree@0.4.1
	thin-vec@0.2.13
	thiserror@1.0.40
	thiserror-impl@1.0.40
	thread_local@1.1.7
	time@0.3.20
	time-core@0.1.0
	time-macros@0.2.8
	tiny-keccak@2.0.2
	tokio@1.28.0
	tokio-macros@2.1.0
	tokio-stream@0.1.14
	toml@0.4.10
	toml@0.8.10
	toml_datetime@0.6.5
	toml_edit@0.22.6
	tracing@0.1.38
	tracing-attributes@0.1.24
	tracing-core@0.1.30
	typenum@1.16.0
	ucd-trie@0.1.5
	unicase@2.6.0
	unicode-bom@1.1.4
	unicode-ident@1.0.8
	unsafe-libyaml@0.2.10
	utf8parse@0.2.1
	version_check@0.9.4
	walkdir@2.3.3
	wasi@0.11.0+wasi-snapshot-preview1
	wasm-bindgen@0.2.91
	wasm-bindgen-backend@0.2.91
	wasm-bindgen-macro@0.2.91
	wasm-bindgen-macro-support@0.2.91
	wasm-bindgen-shared@0.2.91
	watchexec@2.0.0-pre.14
	which@4.4.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.45.0
	windows-sys@0.48.0
	windows-targets@0.42.2
	windows-targets@0.48.0
	windows_aarch64_gnullvm@0.42.2
	windows_aarch64_gnullvm@0.48.0
	windows_aarch64_msvc@0.42.2
	windows_aarch64_msvc@0.48.0
	windows_i686_gnu@0.42.2
	windows_i686_gnu@0.48.0
	windows_i686_msvc@0.42.2
	windows_i686_msvc@0.48.0
	windows_x86_64_gnu@0.42.2
	windows_x86_64_gnu@0.48.0
	windows_x86_64_gnullvm@0.42.2
	windows_x86_64_gnullvm@0.48.0
	windows_x86_64_msvc@0.42.2
	windows_x86_64_msvc@0.48.0
	winnow@0.6.1
"

inherit cargo shell-completion optfeature

DESCRIPTION="A dotfile manager and templater written in rust"
HOMEPAGE="https://github.com/SuperCuber/dotter"
SRC_URI="
	https://github.com/SuperCuber/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"

LICENSE="Unlicense"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD-2 BSD CC-PD CC0-1.0 ISC MIT MPL-2.0 Unicode-DFS-2016
	Unlicense WTFPL-2
"
SLOT="0"
KEYWORDS="~amd64"
IUSE="+scripting +watch"

BDEPEND=">=virtual/rust-1.70"

PATCHES=(
	"${FILESDIR}"/${P}-fix-version.patch
	"${FILESDIR}"/${P}-upgrade-handlebars.patch
)

# 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}"
QA_PRESTRIPPED="${QA_FLAGS_IGNORED}"

src_configure() {
	local myfeatures=(
		$(usev scripting)
		$(usev watch)
	)
	cargo_src_configure --no-default-features
}

src_compile() {
	cargo_src_compile

	target/release/dotter gen-completions --shell bash > bash-completion.sh
	target/release/dotter gen-completions --shell zsh > zsh-completion.zsh
}

src_install() {
	cargo_src_install

	newbashcomp bash-completion.sh ${PN}
	newzshcomp zsh-completion.zsh _${PN}
}

pkg_postinst() {
	optfeature "managing files with different owners" app-admin/sudo
}