# -*- 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/tofuutils/tenv 4.4.0 v
go.offline_build     no
revision             0

homepage             https://tofuutils.github.io/tenv

description          OpenTofu / Terraform / Terragrunt / Atmos version manager
long_description     \
    Versatile version manager for OpenTofu, Terraform, Terragrunt and Atmos. A successor \
    of tofuenv and tfenv.

conflicts            terraform \
                     terragrunt
    
categories           sysutils
license              Apache-2
maintainers          {icloud.com:github.ssk @suhailskhan} \
                     openmaintainer
 
checksums            rmd160  b556266d0ee9db7e40ebe5452d3b7d5f0b9d73d7 \
                     sha256  4ec009b0da3d1645d7ebd674b7f36ac92831946e8d5fff812c352fab041c1d39 \
                     size    808268
 
build.env-append     CGO_ENABLED=0
build.args-append    -o ${worksrcpath}/build/ \
                     -ldflags="-s -w -X main.version=${version}" \
                     ${worksrcpath}/cmd/*

post-build {
    foreach shell {zsh bash fish} {
        system -W ${worksrcpath} "./build/${name} completion ${shell} > tenv.${shell}"
    }
}

destroot {
    foreach bin [glob ${worksrcpath}/build/*] {
        xinstall -m 755 ${bin} ${destroot}${prefix}/bin
    }

    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    xinstall -m 644 ${worksrcpath}/${name}.zsh \
        ${destroot}${prefix}/share/zsh/site-functions/_${name}

    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    xinstall -m 644 ${worksrcpath}/${name}.bash \
        ${destroot}${prefix}/share/bash-completion/completions/${name}

    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d
    xinstall -m 644 ${worksrcpath}/${name}.fish \
        ${destroot}${prefix}/share/fish/vendor_completions.d

    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} \
        CHANGELOG.md LICENSE \
        ${destroot}${prefix}/share/doc/${name}
}

test.run            yes
test.cmd            ${prefix}/bin/tenv help

github.livecheck.regex {([0-9.]+)}
