# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=Portfile:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           python 1.0
PortGroup           select 1.0

github.setup        tmux-python tmuxp 1.47.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                py-tmuxp
revision            0

categories-append   devel
license             MIT
supported_archs     noarch
platforms           {darwin any}

maintainers         {@egorenar posteo.net:egorenar-dev} \
                    {@judaew judaew} openmaintainer

description         tmux session manager.
long_description    {*}${description}

python.versions     310 311 312
python.pep517       yes
python.pep517_backend poetry

if {${name} ne ${subport}} {
    depends_lib-append \
                    port:py${python.version}-click \
                    port:py${python.version}-colorama \
                    port:py${python.version}-kaptan \
                    port:py${python.version}-libtmux

    depends_run-append \
                    port:tmuxp_select

    checksums       rmd160  c4c7dc08ef5c441cddfad8ae25d37e36985b49e1 \
                    sha256  81b9e108d5e296f7a1d13f048b55795db3934ce06e2477e2f84a36d46e8eb056 \
                    size    870161

    select.group    tmuxp
    select.file     ${worksrcpath}/py${python.version}-tmuxp

    post-extract {
        copy -force ${filespath}/tmuxp ${worksrcpath}/py${python.version}-tmuxp
    }

    post-patch {
        reinplace \
            "s,@PYTHON_BRANCH@,${python.branch},g" \
             ${worksrcpath}/${subport}
    }

    post-destroot {
        xinstall -d ${destroot}${prefix}/share/examples/${subport}
        xinstall -m 0644 {*}[glob ${worksrcpath}/examples/*] \
            ${destroot}${prefix}/share/examples/${subport}
    }

    notes "
To make the Python ${python.branch} version of tmuxp the one that is run when\
you execute the commands without a version suffix, e.g. 'tmuxp', run:

port select --set ${select.group} [file tail ${select.file}]
"

    livecheck.type      none
}

github.livecheck.regex  "(\\d+(?:\\.\\d+)+)"
