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

ruby.branches       3.4 3.3 3.2
ruby.setup          rtfm-filemanager 7.0.5 gem {} rubygems
revision            0
categories-append   sysutils
platforms           any
license             Unlicense
maintainers         nomaintainer
description         ${name} is a full-featured terminal file-manager
long_description    {*}${description}
homepage            https://isene.com
checksums           rmd160  ddb11a199bb1b08e99498479186cf5be4a9b1729 \
                    sha256  bff2859d60044de3af6583b5e8c930f454ef2dac64527a25f60c69f2076a40af \
                    size    1593344
supported_archs     noarch

if {${subport} ne ${name}} {
    depends_run-append \
                    port:rb${ruby.suffix}-bootsnap \
                    port:rb${ruby.suffix}-rcurses \
                    port:rb${ruby.suffix}-ruby-openai

    depends_run-append \
                    port:catdoc \
                    port:ffmpegthumbnailer \
                    port:gnumeric \
                    port:highlight \
                    port:ImageMagick \
                    port:ncurses \
                    port:TermMark \
                    port:unzip \
                    port:w3m

    post-destroot {
        # Fix rb-ruby-openai version
        reinplace "s|~> 7.4|>= 7.4|g" ${destroot}${ruby.gemdir}/specifications/${ruby.module}-${version}.gemspec

        # https://github.com/isene/RTFM/issues/8
        reinplace "s|\'bat\' : \'batcat\'|\'bat\' : \'highlight\'|g" ${destroot}${ruby.gemdir}/gems/${ruby.module}-${version}/bin/rtfm
        reinplace "s|-n --color=always|-O ansi --force --line-numbers|g" ${destroot}${ruby.gemdir}/gems/${ruby.module}-${version}/bin/rtfm
        reinplace "s|pandoc \@s -t plain|termmark \@s|g" ${destroot}${ruby.gemdir}/gems/${ruby.module}-${version}/bin/rtfm
    }
}
