# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=todo.txt-cli
pkgver=2.10
pkgrel=2
pkgdesc="A simple and extensible shell script for managing your todo.txt file."
url="https://github.com/todotxt/todo.txt-cli"
arch="noarch"
license="GPL"
depends="bash"
subpackages="$pkgname-bash-completion:bashcomp $pkgname-doc"
source="https://github.com/todotxt/$pkgname/releases/download/v2.10.0/${pkgname/-/_}-$pkgver.tar.gz"

builddir="$srcdir"/${pkgname/-/_}-$pkgver

package() {
	cd "$builddir"
	install -D -m644 todo.cfg $pkgdir/etc/todo.cfg
	install -D -m755 todo.sh $pkgdir/usr/bin/todo.sh
	mkdir -p "$pkgdir"/usr/share/doc/$pkgname
    cat > $pkgdir/usr/share/doc/$pkgname/README.alpine <<EOF

    To use todo.txt-cli fully:
    -------------------------
	* copy /etc/todo.cfg in ~/.todo/config file

	* alias the command "todo.sh" with "t" by adding to ~/.profile (if ash) or ~/bashrc (if bash):
	alias t='todo.sh'
EOF
}

bashcomp() {
	depends=""
	pkgdesc="Bash completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	install -Dm644 "$builddir"/todo_completion \
		"$subpkgdir"/usr/share/bash-completion/completions/${pkgname} || return 1
}


sha512sums="98eb2bdcfb4e76f9313958e46eb8c9c8b68f06fb498b0b43eeb0d9e616a0c9944454fe00a45d6af89e51420f953c624f9e4c969127d478e3f2e76cc9a400d459  todo.txt_cli-2.10.tar.gz"
