# -*- 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/gokcehan/lf 33 r
revision            0
categories          sysutils
maintainers         {judaew @judaew} openmaintainer
license             MIT
platforms           {darwin >= 17}

description         Terminal file manager
long_description    ${name} (as in \"list files\") is a terminal file manager \
                    written in Go. It is heavily inspired by ranger with some \
                    missing and extra features. Some of the missing features \
                    are deliberately omitted since they are better handled by \
                    external tools.

checksums           ${distname}${extract.suffix} \
                        rmd160  0f54ae796714f0e53163967a3dbcde4ee7938e09 \
                        sha256  bb22c16c30200142704e48eb044a8811db7d0f51edeed1662824ceb110da2060 \
                        size    146119

build.pre_args      -ldflags \"-s -w -X main.gVersion=${version}\"

go.vendors          golang.org/x/text \
                        lock    v0.14.0 \
                        rmd160  e26a72d542901d19f6dde4e07746f72206fb8701 \
                        sha256  ef54709caaafdd8b27ce3d5f7c53408f11bc5fd1688c1c4f328de8ed268b3188 \
                        size    8972503 \
                    golang.org/x/term \
                        lock    v0.25.0 \
                        rmd160  ca833ac737fee5ec966abbb66a96939a99bb0cc4 \
                        sha256  b7e1430c8d62c201eeb85b4dabd2801c0bbe7e83cdeb71c35f3e4fa44faed0ad \
                        size    14759 \
                    golang.org/x/sys \
                        lock    v0.26.0 \
                        rmd160  19987e0da1912ad52b2b04531f53e61b342592e6 \
                        sha256  4f47aa2c6f4fede87b4ff8bfb3da47c6b1ddc10bfdb2a5d85a97131f6a459313 \
                        size    1509195 \
                    github.com/rivo/uniseg \
                        lock    v0.4.3 \
                        rmd160  8549c36ce2cf42213bec9682642a6711ef4041f3 \
                        sha256  7578a5eac90d671db12e8ffd6c808ec285af8751bdeaa6a59bddd4341698758a \
                        size    452761 \
                    github.com/mattn/go-runewidth \
                        lock    v0.0.16 \
                        rmd160  297825c4365b5f723ae485e726259ebb620ecd66 \
                        sha256  6c9e81a6b46220612b97ebc35e8d29d1907fd225a9ce3e40b7cebd64cc58d09c \
                        size    18496 \
                    github.com/lucasb-eyer/go-colorful \
                        lock    v1.2.0 \
                        rmd160  a4183d0625e6c94474942cdc544c1061d35c4e34 \
                        sha256  fbad1aade4444bf51409f5b6a008cc14c7a7cdd1af856841fc1170605fae3914 \
                        size    970841 \
                    github.com/gdamore/tcell \
                        lock    v2.7.4 \
                        rmd160  9c47c3776ddce4497bdf09b2045541aa28eacb2b \
                        sha256  d0278f45afc50b1067a8ea8f581289514d73275f11e6c866ca6f7cc34fa18f23 \
                        size    179213 \
                    github.com/gdamore/encoding \
                        lock    v1.0.0 \
                        rmd160  3ed8916f763a5b51db1bcc8bd3ad06cf3d12ec07 \
                        sha256  4f470c7308790bea8a526ea26cecbaa22345aad8dc566821cda6175b3d241ee1 \
                        size    10900 \
                    github.com/fsnotify/fsnotify \
                        lock    v1.7.0 \
                        rmd160  9198dec094f5008a8b24a2e51542ce4ec3453162 \
                        sha256  d7cd46fbc8e25bfd37edb1b86851dcccc18c5180f09e533c6a35e4dcf2693d22 \
                        size    57508 \
                    github.com/djherbis/times \
                        lock    v1.6.0 \
                        rmd160  74bbca79275e2c9a5c240f77e906b640b69543a7 \
                        sha256  2b1e000f0c9408eb4d7735547a95e65860d6c2d7411ef70558db6b2b5d526f1f \
                        size    8891

patchfiles          patch-config-file-in-prefix.diff

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/os.go
}

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

    # Install shell completion files
    set bash_complete ${destroot}${prefix}/share/bash-completion/completions
    xinstall -d ${bash_complete}
    xinstall -m 0644 ${worksrcpath}/etc/${name}.bash \
        ${bash_complete}/${name}

    set zsh_complete ${destroot}${prefix}/share/zsh/site-functions
    xinstall -d ${zsh_complete}
    xinstall -m 0644 ${worksrcpath}/etc/${name}.zsh \
        ${zsh_complete}/_${name}

    set fish_complete ${destroot}${prefix}/share/fish/vendor_completions.d
    xinstall -d ${fish_complete}
    xinstall -m 0644 ${worksrcpath}/etc/${name}.fish \
        ${fish_complete}/${name}.fish

    set tcsh_complete ${destroot}${prefix}/etc/profile.d
    xinstall -d ${tcsh_complete}
    xinstall -m 0644 ${worksrcpath}/etc/${name}.csh \
        ${tcsh_complete}/${name}.csh

    # Install vim plugin, man-page, lfcd shell scripts and docs
    set vim_plugin ${destroot}${prefix}/share/vim/vimfiles/ftdetect
    xinstall -d ${vim_plugin}
    xinstall -m 0644 ${worksrcpath}/etc/${name}.vim ${vim_plugin}/

    xinstall -m 0644 ${worksrcpath}/${name}.1 \
        ${destroot}${prefix}/share/man/man1

    xinstall -d ${destroot}${prefix}/share/${name}
    xinstall -m 0644 -W ${worksrcpath}/etc \
        lfcd.sh lfcd.csh lfcd.fish \
        ${destroot}${prefix}/share/${name}
    xinstall -m 0644 -W ${worksrcpath} LICENSE README.md \
        ${destroot}${prefix}/share/${name}

    xinstall -d ${destroot}${prefix}/etc/${name}
    xinstall -m 0644 -W ${worksrcpath}/etc \
        colors.example icons.example lfrc.example \
        ${destroot}${prefix}/etc/${name}
}

notes "
A sample configuration file can be found at the following path:
    ${prefix}/etc/${name}/lfrc.example

The Vim plugin is already included within the port and installed in Vim's
global plugin directory. If you are using Neovim, add the following line to
your init.vim:
    set rtp+=${prefix}/share/vim/vimfiles/ftdetect

lfcd is a shell script that changes the working directory in your shell to
the last directory in lf on exit, a feature adapted from ranger. If you want
to use this script, you need to source it in a smilar way as with sourcing
completions for any given shell. You can find the script on the following
path:
    ${prefix}/share/${name}
"
