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

github.setup        ahmetb kubectx 0.9.5 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            1
categories          sysutils
platforms           any
supported_archs     noarch
maintainers         {breun @breun} @gearnode openmaintainer
license             Apache-2

description         Power tools for kubectl
long_description    kubectx helps you switch between clusters back and forth. \
                    kubens helps you switch between Kubernetes namespaces smoothly.

checksums           rmd160  d83ba4c5db6a0500e258a2dc7ca4c3b30e8c4567 \
                    sha256  e823287ad55864b1f96d9c79191159bfc489f821ec4996299edbe5829e214583 \
                    size    523315

depends_run         path:${prefix}/bin/kubectl:kubectl-1.27

use_configure       no
build {}

destroot    {
    set doc_dir ${destroot}${prefix}/share/${name}
    xinstall -d ${doc_dir}
    xinstall -m 644 -W ${worksrcpath} \
        CONTRIBUTING.md \
        LICENSE \
        README.md \
        ${doc_dir}

    set bin_dir ${destroot}${prefix}/bin
    xinstall -m 755 -W ${worksrcpath} \
        kubectx \
        kubens \
        ${bin_dir}

    set src_completion_dir ${worksrcpath}/completion

    set zsh_completion_dir ${destroot}${prefix}/share/zsh/site-functions
    xinstall -d ${zsh_completion_dir}
    xinstall -m 644 ${src_completion_dir}/_kubectx.zsh ${zsh_completion_dir}/_kubectx
    xinstall -m 644 ${src_completion_dir}/_kubens.zsh ${zsh_completion_dir}/_kubens

    set bash_completion_dir ${destroot}${prefix}/etc/bash_completion.d
    xinstall -d ${bash_completion_dir}
    xinstall -m 644 ${src_completion_dir}/kubectx.bash ${bash_completion_dir}/kubectx
    xinstall -m 644 ${src_completion_dir}/kubens.bash ${bash_completion_dir}/kubens

    set fish_completion_dir ${destroot}${prefix}/share/fish/vendor_completions.d
    xinstall -d ${fish_completion_dir}
    xinstall -m 644 ${src_completion_dir}/kubectx.fish ${fish_completion_dir}/
    xinstall -m 644 ${src_completion_dir}/kubens.fish ${fish_completion_dir}/
}
