# -*- 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/hetznercloud/cli 1.65.0 v
revision            0

name                hcloud
categories          devel
license             MIT
maintainers         {judaew @judaew} openmaintainer

description         ${name} is a command-line interface for Hetzner Cloud.
long_description    {*}${description}

checksums           ${distname}${extract.suffix} \
                        rmd160  42916cb3e22c69882f70ae8e06da1900fa05d49b \
                        sha256  85a9d35760c0f694c32a7aa07eac454f48e47b8e826fef8c9d28a720b3d3a17e \
                        size    304252

build.pre_args-append   -ldflags \
    '-X ${go.package}/internal/version.Version=${version}'
build.args              ./cmd/${name}

# FIXME: This port currently can't be built without allowing go mod to fetch
# The port needs version of the protobuf from go.googlesource.com, which is not
# available at github.com/golang/protobuf.
go.offline_build no

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

    # The shell completions
    set bash_complete ${prefix}/share/bash-completion/completions
    xinstall -d ${destroot}${bash_complete}
    exec ${destroot}${prefix}/bin/${name} completion bash >> \
        ${destroot}${prefix}/share/bash-completion/completions/${name}

    set zsh_complete ${prefix}/share/zsh/site-functions
    xinstall -d ${destroot}${zsh_complete}
    exec ${destroot}${prefix}/bin/${name} completion zsh >> \
        ${destroot}${prefix}/share/zsh/site-functions/_${name}

    set fish_complete ${prefix}/share/fish/vendor_completions.d
    xinstall -d ${destroot}${fish_complete}
    exec ${destroot}${prefix}/bin/${name} completion fish >> \
        ${destroot}${prefix}/share/fish/vendor_completions.d/${name}.fish
}

# overload the github livecheck regex to look for versions that
github.livecheck.regex  {([0-9.]+)}
