# -*- 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 41 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  4e802992f27bef90fd186f1b2b05daded8ee2173 \
                        sha256  55c556d53b5541d5f8691f1309a0166a7a0d8e06cb051c3030c2cd7d8abc6789 \
                        size    197515

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

go.vendors          golang.org/x/text \
                        lock    v0.29.0 \
                        rmd160  5f9ac2f866ae9a0e481eecc66f4a4a2cc4447ab6 \
                        sha256  05d0a260c209629337dc6db8e49fb4fe57a6e20e21925007b60f183655d27174 \
                        size    8974653 \
                    golang.org/x/term \
                        lock    v0.39.0 \
                        rmd160  2090fd96a2cf03020445ff6c12a146b233c55628 \
                        sha256  de9f5aa1cd36db1f5411078495d32c4096866fe11cd09417a302ebb68c9c73d8 \
                        size    16453 \
                    golang.org/x/sys \
                        lock    v0.40.0 \
                        rmd160  c1b624cb03ef33de844391c537ff616763e6a6b3 \
                        sha256  5ca4e94b4d1e7822df2414ab990885117d7266f1fcddf25e28432ab3aab66665 \
                        size    1536154 \
                    github.com/mattn/go-runewidth \
                        lock    v0.0.19 \
                        rmd160  b0f62e2f1c2086189f2ed14ad635733c4e5ced56 \
                        sha256  6f5a00cdfbf4d88d05406a07bb95c34dc0abc2f65f15e9c5ca35814f4008b82f \
                        size    20550 \
                    github.com/lucasb-eyer/go-colorful \
                        lock    v1.3.0 \
                        rmd160  f32cca200fcf4db4d0e51cc457baf68f212d8965 \
                        sha256  4168f7454b19120873f75a67d1eeb7be312ea852542e21db1a96b65e514e56c2 \
                        size    982361 \
                    github.com/gdamore/tcell/v2 \
                        lock    v2.9.0 \
                        rmd160  42fdfbfc44d5b802ce6190738e53db8779785205 \
                        sha256  cef3c5c649a976b48002526414775c97ae67a4eb7ea78a6a1ffc53c4f1e65859 \
                        size    187497 \
                    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/clipperhouse/uax29/v2 \
                        lock    v2.2.0 \
                        rmd160  9d56b6ecadc9b977922cf1a9763f1c4a8496f995 \
                        sha256  dd907ccd83af2897b812f34920729d88c31809ea5526973978f4eab7b80b5237 \
                        size    279573

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