# -*- 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/alajmo/mani 0.32.0 v
revision            0

homepage            https://manicli.com

description         CLI tool to help you manage repositories

long_description    \
    ${name} is a CLI tool that helps you manage multiple repositories. It's \
    useful when you are working with microservices, multi-project systems, \
    many libraries or just a bunch of repositories and want a central place \
    for pulling all repositories and running commands over them. You specify \
    repository and commands in a config file and then run the commands over \
    all or a subset of the repositories.

categories          devel
installs_libs       no
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  7818f5fafcb57a94b742b430bd240e1bbc185559 \
                    sha256  63151cc156130b335b1f844c6e88049670647c44d4a42516510a9fd70edff9b0 \
                    size    932011

# Allow Go to fetch deps at build time
go.offline_build no

build.cmd           make
build.pre_args      DATE=""
build.args          build

post-build {
    # Generate shell completions for supported shells
    foreach shell {bash fish zsh} {
        system -W ${worksrcpath}/dist \
            "./${name} completion ${shell} > ${name}.${shell}"
    }
}

destroot {
    xinstall -m 0755 ${worksrcpath}/dist/${name} ${destroot}${prefix}/bin/

    set bash_comp_path ${destroot}${prefix}/share/bash-completion/completions
    xinstall -m 0755 -d ${bash_comp_path}
    xinstall -m 0644 ${worksrcpath}/dist/${name}.bash ${bash_comp_path}/${name}

    set fish_comp_path ${destroot}${prefix}/share/fish/vendor_completions.d
    xinstall -m 0755 -d ${fish_comp_path}
    xinstall -m 0644 ${worksrcpath}/dist/${name}.fish ${fish_comp_path}

    set zsh_comp_path ${destroot}${prefix}/share/zsh/site-functions
    xinstall -m 0755 -d ${zsh_comp_path}
    xinstall -m 0644 ${worksrcpath}/dist/${name}.zsh ${zsh_comp_path}/_${name}

    xinstall -m 0755 -d ${destroot}${prefix}/share/man/man1
    xinstall -m 0444 ${worksrcpath}/core/mani.1 ${destroot}${prefix}/share/man/man1
}
