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

name                carapace
version             1.6.1
revision            0

go.setup            github.com/carapace-sh/carapace-bin ${version} v

categories          sysutils
maintainers         {gmail.com:esafak @esafak} openmaintainer
license             MIT
description         Command-line interface completion framework
long_description    Carapace provides multi-shell (bash, zsh, fish, powershell) \
                    completions for CLI programs.

homepage            https://carapace.sh/

checksums           rmd160  d5cb3eeb81c5bd4a17479275cbc906e7fb63f8e4 \
                    sha256  bbc038b1d2b75d5a6ee089f43070cc2bab2147ff4071ffe7c586179521fb57f7 \
                    size    21070615

build {
    system -W ${worksrcpath} "${go.bin} generate ./..."
    system -W ${worksrcpath} "${go.bin} build -v -o ${worksrcpath}/carapace -ldflags '-s -w -X main.version=${version}' -tags release ./cmd/carapace"
}

destroot {
    xinstall -m 755 ${worksrcpath}/carapace ${destroot}${prefix}/bin/carapace

    # Create directories for completions
    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d
    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    xinstall -d ${destroot}${prefix}/share/nushell/completions

    # Generate and install shell completion scripts
    system "${destroot}${prefix}/bin/carapace completion bash > ${destroot}${prefix}/share/bash-completion/completions/carapace"
    system "${destroot}${prefix}/bin/carapace completion fish > ${destroot}${prefix}/share/fish/vendor_completions.d/carapace.fish"
    system "${destroot}${prefix}/bin/carapace completion zsh > ${destroot}${prefix}/share/zsh/site-functions/_carapace"
    system "${destroot}${prefix}/bin/carapace completion nushell > ${destroot}${prefix}/share/nushell/completions/carapace.nu"
}

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