# -*- 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/rest-sh/restish 2.3.0 v
go.package          github.com/rest-sh/restish/v2
go.toolchain_min    1.25.3
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  50f5b0e5dbee301f027dcc48a6f3158c9ee41d21 \
                    sha256  b80dfebc06288d8ce6ca1e83fb1b848e345958001d878220b9fa17ae702a7dc5 \
                    size    2364717

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

# The command moved under cmd/ upstream; building the module root produces
# no binary. The version variable moved out of package main too.
build.args-append   ./cmd/${name}
build.pre_args-append \
    -ldflags \"-X ${go.package}/internal/cli.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
}
