# -*- 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/nickawilliams/diffscribe 0.3.0 v
go.offline_build    no

categories          devel
license             BSD
maintainers         {@nickawilliams users.noreply.github.com:nickawilliams} openmaintainer

description         Ask an LLM to craft helpful commit messages for your staged Git changes.
long_description    {*}${description}
homepage            https://github.com/nickawilliams/diffscribe

checksums           rmd160  41a707ea73b394ac2ff430d2d56bc93063046548 \
                    sha256  96c529366368598723626c7fc113561997298a3b53a3c2613dbd8924f59cb268 \
                    size    124314

build.env-append    CGO_ENABLED=0
build.args          -o ${worksrcpath}/${name} \
                    -trimpath \
                    -ldflags \" \
                        -s \
                        -w \
                        -X github.com/nickawilliams/diffscribe/internal/version.version=${version} \
                    \" \
                    ./

post-build {
    system -W ${worksrcpath} "CGO_ENABLED=0 ${go.bin} run ./tools/gen-man"
}

test.run            yes
test.cmd            ${worksrcpath}/${name}
test.args           --version

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

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

    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d
    xinstall -m 0644 ${worksrcpath}/contrib/completions/fish/${name}.fish \
        ${destroot}${prefix}/share/fish/vendor_completions.d/${name}.fish

    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    xinstall -m 0644 ${worksrcpath}/contrib/completions/zsh/${name}.zsh \
        ${destroot}${prefix}/share/zsh/site-functions/_${name}

    if {[file exists ${worksrcpath}/contrib/man/${name}.1]} {
        xinstall -d ${destroot}${prefix}/share/man/man1
        xinstall -m 0644 ${worksrcpath}/contrib/man/${name}.1 \
            ${destroot}${prefix}/share/man/man1/${name}.1
    }
}
