# -*- 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           golang 1.0

go.setup            github.com/homeport/dyff 1.8.0 v
go.offline_build    no
github.tarball_from archive
revision            0

description         diff tool for YAML files, and sometimes JSON
long_description    {*}${description}

categories          textproc
installs_libs       no
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  1c8066b1388cf067143256f9428e23861e9769fd \
                    sha256  f04e155c1691e82cf9cfc5aedfce95d32f70a120e173d4d23c53ca6549182278 \
                    size    1212045

build.pre_args-append \
    -ldflags \"-X ${go.package}/internal/cmd.version=${version}\"
build.args          ./cmd/${name}

post-build {
    # Generate completion files
    file mkdir ${worksrcpath}/completion

    foreach _shell {bash fish zsh} {
        system -W ${worksrcpath} \
            "./${name} completion ${_shell} > ./completion/${name}.${_shell}"
    }
}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/

    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    copy ${worksrcpath}/completion/${name}.bash \
        ${destroot}${prefix}/share/bash-completion/completions/${name}

    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d
    copy ${worksrcpath}/completion/${name}.fish \
        ${destroot}${prefix}/share/fish/vendor_completions.d/

    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    copy ${worksrcpath}/completion/${name}.zsh \
        ${destroot}${prefix}/share/zsh/site-functions/_${name}
}
