# -*- 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.0 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  db2b6492355dbdb5825917d72e6714f8d6c71f5e \
                    sha256  9a73e743a78d6a28e2ff0dba53499b23c945c45f78b4a0ab3aa4b6283491de5d \
                    size    316109

# 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
}
