# -*- 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.6.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  49ba521e86f3dda47beacebfb9f16d8be5403dfa \
                    sha256  f6abe54b433c30557c49aa41d351ec97ef24b4bee3f9dbc91e7db8f366592f99 \
                    size    137077

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
}
