# -*- 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/jenkins-zh/jenkins-cli 0.0.47 v
revision            0
set git_commit      c926d60
categories          devel
license             MIT

maintainers         {@harens harens} openmaintainer
description         Allows you manage your Jenkins as an easy way
long_description    Jenkins CLI allows you manage your Jenkins in an easy way. \
                    No matter if you're a plugin developer, administrator or just a \
                    regular user, it is made for you!

# Name of the executable
set short           jcli

homepage            https://${short}.jenkins-zh.cn

checksums           ${distname}${extract.suffix} \
                        rmd160  3ad5e43ded1301cbdf6b5ad5c68720976818b559 \
                        sha256  4e78600e214c357c08a0a83fe9cc59214b0d050de07dbb469d9f226c8c37eabc \
                        size    227265

# Allows for version number, last commit and build date in `jcli version`
# Suppress build date for reproducible builds
set build_date      SUPPRESSED
set cobra_extension github.com/linuxsuren/cobra-extension/version

# Issues with vendored deps: allow fetching deps at build time
go.offline_build no

build.args          -ldflags \
                      '-X ${cobra_extension}.date=${build_date} \
                       -X ${cobra_extension}.commit=${git_commit} \
                       -X ${cobra_extension}.version=${version}'

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

post-destroot {

    copy ${worksrcpath}/docs/book \
        ${destroot}${prefix}/share/doc/${name}

    # Docs files that aren't in the books dir
    foreach f {CONTRIBUTING.md LICENSE README-zh.md} {
            copy ${worksrcpath}/${f} ${destroot}${prefix}/share/doc/${name}
    }

    # bash completion
    set bash_completion_dir ${destroot}${prefix}/share/bash-completion/completions
    xinstall -d ${bash_completion_dir}
    system -W ${worksrcpath} "${worksrcpath}/${name} completion --type bash > ${bash_completion_dir}/${short}"

    # fish completion
    set fish_completion_dir ${destroot}${prefix}/share/fish/vendor_completions.d
    xinstall -d ${fish_completion_dir}
    system -W ${worksrcpath} "${worksrcpath}/${name} completion --type fish > ${fish_completion_dir}/${short}.fish"

    # zsh completion
    set zsh_completion_dir ${destroot}${prefix}/share/zsh/site-functions
    xinstall -d ${zsh_completion_dir}
    system -W ${worksrcpath} "${worksrcpath}/${name} completion --type zsh > ${zsh_completion_dir}/_${short}"
}
