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

name                apple-completion
github.setup        Honestpuck apple_complete 32e6ac89dc1bd267821f54f3181260dc4be38e6b
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             0.1-20210108
revision            0

categories          devel
platforms           any
supported_archs     noarch
license             Apache-2

maintainers         {mascguy @mascguy} \
                    openmaintainer

description         Bash completions for Apple command-line tools
long_description \
  These are a number of scripts designed to add programmable completion to \
  Bash for some of the Apple command line tools.

checksums           rmd160  1c9403837bb91529ea608a78bbfe6ce6567b1d5c \
                    sha256  3671eb24cfc66f3c8987ed26e331fe8ba73a0f4115a421e11cea5a582d0c227f \
                    size    9879

depends_run         port:bash

use_configure       no

set compdir_bash \
    ${destroot}${prefix}/etc/bash_completion.d

set doc_dir \
    ${destroot}${prefix}/share/doc/${name}

set doc_files \
    [list \
        LICENSE.txt \
        README.md \
        TODO.md \
    ]

build {}

pre-destroot {
    xinstall -d ${doc_dir}
    xinstall -d ${compdir_bash}
}

destroot {
    set apple_completions \
        [glob -nocomplain -type f \
            -directory ${worksrcpath} \
            *]

    foreach fpath ${apple_completions} {
        set fn [file tail ${fpath}]

        if {[lsearch -exact ${doc_files} ${fn}] < 0} {
            xinstall -m 644 ${fpath} \
                ${compdir_bash}/${fn}
        } else {
            xinstall -m 644 ${fpath} \
                ${doc_dir}/${fn}
        }
    }
}

notes {
    These completions are based on the latest macOS releases. As such, if you\
    are running on an older macOS version, some verbs/options may not be\
    supported.
}
