# -*- 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 35 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  d002923f290de4676dcd42a542f41cf467103be1 \
                        sha256  bf2ecd63eb75ceeb88f42977d49515bbd755b7f3d4db651a097c6ba47fd2d989 \
                        size    150705

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

go.vendors          golang.org/x/text \
                        lock    v0.24.0 \
                        rmd160  b181709ec4248be6a143e2448942748f081b2f50 \
                        sha256  329c3d21dc0465c090733bdb87cc596776a8492901411be9024028af808903ac \
                        size    8974645 \
                    golang.org/x/term \
                        lock    v0.31.0 \
                        rmd160  9955bd92d2cc8266fab627e129f4f17cbf1ec66a \
                        sha256  62582c2da67b0726f8a32170383edc9ca3bc63bf67e72a4508a76f7cfd072f9e \
                        size    14905 \
                    golang.org/x/sys \
                        lock    v0.32.0 \
                        rmd160  be748f58461f9537913e1ce3b69815e4a7e4c8c6 \
                        sha256  82c933346569d1a26b3ca51991dc2dd805f6ae4e55b5a1da8bc19ca0c204da34 \
                        size    1526498 \
                    github.com/rivo/uniseg \
                        lock    v0.4.7 \
                        rmd160  a9056dc9a2a80aa9c46d0ff9e54f9e2e5a498c41 \
                        sha256  abc6a2f17b64b34b8a0c56eb9d0b53886ebbe0c88d467755c09c7fa696a16677 \
                        size    458166 \
                    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.8.1 \
                        rmd160  0fbf5bc67e01706b0fca0930090d9e0fab35eec6 \
                        sha256  088141739e49263b0e44b18b768a11b092281c4b54c443bdeaa122232b259d94 \
                        size    187858 \
                    github.com/gdamore/encoding \
                        lock    v1.0.1 \
                        rmd160  7e73cab014fe3647552b67678a397ba5ce2475e9 \
                        sha256  dc7a586abe34b2d9562ca2aed225a1db734cc8b548a89bb238e75251d9aa0344 \
                        size    14814 \
                    github.com/fsnotify/fsnotify \
                        lock    v1.9.0 \
                        rmd160  24b514b003e8a613b938e13f7df3ba60dc755499 \
                        sha256  46aaaf931594e32ce1e087da58dc8d3e27f0e34eaca38a9280f6c10a198d4166 \
                        size    73949 \
                    github.com/djherbis/times \
                        lock    v1.6.0 \
                        rmd160  74bbca79275e2c9a5c240f77e906b640b69543a7 \
                        sha256  2b1e000f0c9408eb4d7735547a95e65860d6c2d7411ef70558db6b2b5d526f1f \
                        size    8891 \
                    github.com/Xuanwo/go-locale \
                        lock    v1.1.3 \
                        rmd160  63a2d6daeb4ca03e908ceaa1725209a418721f10 \
                        sha256  31cfdd7f485d9f72062215a3c6491bc7a4061e512999ee30bd3eadf558ed8047 \
                        size    15444

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}
"
