# -*- 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
# $Id: Portfile 115720 2014-01-09 20:44:48Z snc@macports.org $

PortSystem          1.0
PortGroup           github 1.0

github.setup        ginatrapani todo.txt-cli 2.10 v
name                todotxt
categories          office
license             GPL
maintainers         snc 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.

platforms           darwin

checksums           rmd160  2e09d0ab6c841048e885fd54ab54e637280375d5 \
                    sha256  d58cd727fe5cab58615655cc46b43f7392c8a540b561247c8d9a23844523cbe5

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
    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
}

variant bash_completion {
    depends_run-append  path:etc/bash_completion:bash-completion
}

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