# Contributor: Philipp Glaum <p@pglaum.de>
# Maintainer: Dhruvin Gandhi <contact@dhru.vin>
pkgname=todoman
_pyname=todoman
pkgver=4.4.0
pkgrel=3
pkgdesc="Simple iCalendar-based todo manager"
url="https://pypi.org/project/todoman/"
arch="noarch"
license="ISC"
depends="
	python3
	py3-atomicwrites
	py3-click
	py3-click-log
	py3-dateutil
	py3-humanize
	py3-icalendar
	py3-parsedatetime
	py3-urwid
	py3-xdg
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-setuptools_scm
	py3-sphinx
	py3-sphinx-autorun
	py3-sphinx-click
	py3-sphinx_rtd_theme
	py3-wheel
	"
checkdepends="
	py3-freezegun
	py3-hypothesis
	py3-pytest
	py3-pytest-cov
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion:zshcomp:noarch
	$pkgname-pyc
	$pkgname-repl:repl:noarch
	"
source="https://files.pythonhosted.org/packages/source/${_pyname:0:1}/$_pyname/$_pyname-$pkgver.tar.gz"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
	make -C docs man PYTHONPATH="$PWD"
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	TZ=UTC .testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl
	install -Dm644 docs/build/man/todo.1 "$pkgdir"/usr/share/man/man1/todo.1
	install -Dm644 contrib/completion/bash/_todo \
		"$pkgdir"/usr/share/bash-completion/completions/_todo
	install -Dm644 contrib/completion/zsh/_todo \
		"$pkgdir"/usr/share/zsh/site-functions/_todo
}

zshcomp() {
	default_zshcomp
	depends="$depends jq"
}

repl() {
	depends="py3-click-repl $pkgname=$pkgver-r$pkgrel"
	pkgdesc="Simple iCalendar based todo manager (interactive shell)"
	install -d "$subpkgdir"
}

sha512sums="
02eb38ac44033371496ba94bab5a0a909d0df56dd10e2de7c3c80ea325bd16d4389effa0d6d2be87cf31d3debf6d0c48cddf4cd185b7c50b4168f924548459cf  todoman-4.4.0.tar.gz
"
