# -*- 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            git.sr.ht/~xenrox/hut 0.7.0 v
revision            0

description         A CLI tool for sr.ht.

long_description    ${name} lets you interact with the SourceHut API from the \
                    command line. See the man page for a full list of \
                    available commands.

categories          devel
installs_libs       no
license             AGPL-3
maintainers         {woolsweater.net:macports @woolsweater} \
                    openmaintainer

checksums           rmd160  a83badd9d13aa599d63dcb60623fe2ea189cfdc5 \
                    sha256  5975f940740dd816057ab3cf20cebde3ece3250891952a566f8555f73fb67b21 \
                    size    149392

depends_build-append \
                    port:scdoc

# Tarball contents name conflicts with the default work dir name
worksrcdir          ${name}-${version}-${epoch}

# Allow Go to fetch dependencies at build time
go.offline_build no

build.cmd           \
    ${build.cmd} -ldflags \" \
        -X main.version=v${version} -X main.builtBy=macports \
    \" \&\& \
    make completions doc/${name}.1

destroot {
    # install binary:
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/

    # install man page:
    xinstall -m 0644 \
        ${worksrcpath}/doc/${name}.1 \
        ${destroot}${prefix}/share/man/man1/${name}.1

    # install shell completions:
    # bash:
    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    file copy ${worksrcpath}/${name}.bash \
        ${destroot}${prefix}/share/bash-completion/completions/${name}

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

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