# Contributor: Edd Salkield <edd@salkield.uk>
# Maintainer: Edd Salkield <edd@salkield.uk>
pkgname=timewarrior
pkgver=1.7.1
pkgrel=0
pkgdesc="command line time tracking and reporting"
url="https://timewarrior.net"
arch="all"
license="MIT"
depends="python3"
makedepends="cmake asciidoctor samurai"
checkdepends="py3-dateutil mandoc"
subpackages="$pkgname-doc"
source="timewarrior-v$pkgver.tar.gz::https://github.com/GothenburgBitFactory/timewarrior/releases/download/v$pkgver/timew-$pkgver.tar.gz"
builddir="$srcdir/timew-$pkgver"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

check() {
	ninja -C build test
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# install the refresh holiday scripts in /usr/bin/ for user convenience
	chmod 755 "$pkgdir/usr/share/doc/timew/holidays/refresh"
	ln -s /usr/share/doc/timew/holidays/refresh "$pkgdir/usr/bin/timew-refresh-holidays"

	# remove useless man pages
	rm -r "$pkgdir"/usr/share/man/
}

sha512sums="
f28f6c47cc05d8055cc3fae9e96d1936554c685090a40f8af1995e5357947cb9bdfab0ec091f68693a566a876e06eda502de074900f7368a913e85d7e4cf87f1  timewarrior-v1.7.1.tar.gz
"
