# -*- 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 42 r
go.toolchain_min    1.25.0
revision            0
categories          sysutils
maintainers         {judaew @judaew} openmaintainer
license             MIT

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  1270d10aa9603b6f0853ab14a07d85690ac5c7a0 \
                        sha256  7a8f7c2c86419270b713b6235dced7b9d0e68732e74a1e0f375f774fff4023ca \
                        size    205836

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

go.vendors          golang.org/x/text \
                        lock    v0.40.0 \
                        rmd160  75205b5abd0d36bd9508c4cf056b035a02e39739 \
                        sha256  35fdb039fb974052bc42cd655ee47c141298f1a1962279828e921c6f7130a0d8 \
                        size    6772390 \
                    golang.org/x/term \
                        lock    v0.45.0 \
                        rmd160  2ff34ce76d39e5ca3ff919a7539d425debb3ebda \
                        sha256  f71934454e5fc440c2eb43e9739cd9bd91c1014883faf65d65159717ff2bd875 \
                        size    16446 \
                    golang.org/x/sys \
                        lock    v0.47.0 \
                        rmd160  1be59a8208fd6f7f4319b306138e77f215293e1a \
                        sha256  2bed220513067f721fc7c19314bab58860c28397f5e48093a8fe35a27a915b06 \
                        size    1551474 \
                    github.com/lucasb-eyer/go-colorful \
                        lock    v1.4.0 \
                        rmd160  96dc7dfa29a7e7f4e7b72ccedcd226efe0fbcb94 \
                        sha256  990b1f3429d6beff3a51c7e534b95999874ea27a61b31b425b5a8ae994843c37 \
                        size    986501 \
                    github.com/gdamore/tcell/v3 \
                        lock    v3.4.1 \
                        rmd160  f6c603571acafdff9d861cfec0ffe3a051e16641 \
                        sha256  8c82f2d1c59008a04f2322edca0c490b773d2c5c1f679588b9faaf1965d5ed63 \
                        size    392441 \
                    github.com/gdamore/encoding \
                        lock    v1.0.1 \
                        rmd160  7e73cab014fe3647552b67678a397ba5ce2475e9 \
                        sha256  dc7a586abe34b2d9562ca2aed225a1db734cc8b548a89bb238e75251d9aa0344 \
                        size    14814 \
                    github.com/fsnotify/fsnotify \
                        lock    v1.10.1 \
                        rmd160  b588a8981513c3c51232591edc94fe223aee7e7c \
                        sha256  e4a21cb263e96a4598bdfa662e315a0a227b8be58a6525f94c8b531afdbfe66e \
                        size    76945 \
                    github.com/djherbis/times \
                        lock    v1.6.0 \
                        rmd160  74bbca79275e2c9a5c240f77e906b640b69543a7 \
                        sha256  2b1e000f0c9408eb4d7735547a95e65860d6c2d7411ef70558db6b2b5d526f1f \
                        size    8891 \
                    github.com/clipperhouse/uax29/v2 \
                        lock    v2.7.0 \
                        rmd160  9cd62348ce0722d85ff21f2f91a05a68f877aa08 \
                        sha256  66d66a451f74709ab74902e7bca146abf376dbf0bc701b713ee600e3d3d6a5b3 \
                        size    320846 \
                    github.com/clipperhouse/displaywidth \
                        lock    v0.11.0 \
                        rmd160  26a2f5e784f0414e55714156bab744b0d901c5c1 \
                        sha256  d9587478830f552e284be30f010c2e57be7679d5c883a256b9df4b6889827347 \
                        size    250271

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