# -*- 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.5.3
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  998ff8b3161755df96f7f8724258adf3564e5317 \
                    sha256  4372fa39ab82903d09fa22a1d2f03fe2a1f6fa1d1f7643759d5bb937ad876bd3 \
                    size    18672260

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.]+)}
