# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

github.setup        todotxt todo.txt-cli 2.12.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                todotxt
categories          office
license             GPL-3
maintainers         {snc @nerdling} openmaintainer
supported_archs     noarch

description         Simple, extensible shell script to manage your todo file.
long_description    A simple and extensible shell script for managing your \
                    todo.txt file.

homepage            http://todotxt.org
platforms           any

dist_subdir         ${name}/${version}_1
checksums           rmd160  18d0e7546ae1797c7c1c2584e7c797e83832eda5 \
                    sha256  1044902df08b7b11bae950377e14283a2a2b74fa18427b44f6074f2767faa803 \
                    size    716514

use_configure       no

build {}

post-patch {
    reinplace "s/todo\\.sh/${name}/" ${worksrcpath}/todo_completion
}

destroot {
    xinstall -m 755 ${worksrcpath}/todo.sh ${destroot}${prefix}/bin/$name
    ln -s $name ${destroot}${prefix}/bin/todo.sh
    xinstall -d -m 755 ${destroot}${prefix}/share/${name}
    xinstall -m 644 ${worksrcpath}/todo.cfg ${destroot}${prefix}/share/${name}/todo.cfg-dist
}

post-destroot {
    set completions_path ${destroot}${prefix}/share/bash-completion/completions
    xinstall -d ${completions_path}
    xinstall -m 644 ${worksrcpath}/todo_completion ${completions_path}/${name}
}

patch {
    # default cfg will try to write in ${prefix}/bin, since this isn't obvious from the config
    # file we help the user avoiding this
    reinplace "s|TODO_DIR=\$\(dirname \"\$0\"\)|TODO_DIR=\"\$HOME\"/.todo|" ${worksrcpath}/todo.cfg
}

notes "Copy the default configuration file from  ${prefix}/share/${name}/todo.cfg-dist \
to  ~/.todo/config  and customize it."
