# -*- 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/danielgtaylor/restish 0.21.2 v
revision            0

homepage            https://rest.sh

description         \
    Restish is a CLI for interacting with REST-ish HTTP APIs with some nice \
    features built-in

long_description    \
    {*}${description}, like always having the latest API resources, fields, \
    and operations available when they go live on the API without needing to \
    install or update anything.

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

checksums           rmd160  f8578e967bf04621e952e4a49c9fe2eecaa7f471 \
                    sha256  3686e652193c976a04c96f83ee1a78571509e22169b83f7212a7380b374d24b1 \
                    size    316611

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

build.pre_args-append \
    -ldflags \"-X main.version=${version}\"

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

    file mkdir ${worksrcpath}/_completions

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

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

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

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