mtx-context-setups.tex / last modification: 2020-01-30 14:16
%D \module
%D   [       file=mtx-context-setups,
%D        version=2016.04.05,
%D          title=\CONTEXT\ Command Overvews,
%D       subtitle=Combine Files,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% begin help
%
% usage: context --extra=setups [options] [categories]
%
% --interface              : user interface (en, nl, etc)
% --overview [--save]      : use collection of files
% --list                   : show know collections
%
% end help

\input mtx-context-common.tex

\starttext

\startluacode
    local report_setups = logs.reporter("setups")

    context.starttext()

    if document.arguments.list then
        local okay = resolvers.findfile("context.mkiv") or "" -- will become an i file
        if okay ~= "" then
            okay = file.collapsepath(okay,true)
            okay = string.gsub(okay,"/base/","/interface/")
            okay = string.gsub(okay,"/sources/","/interface/")
            local path    = file.pathpart(okay)
            local pattern = file.join(path,"i-*.xml")
            local files   = dir.glob(pattern)
            local valid   = { }
            table.sort(files)
            for i=1,#files do
                local name = file.nameonly(files[i])
                local base = string.match(name,"^i%-([a-z]+)$")
                if base then
                    valid[#valid+1] = base
                end
            end
            if #valid > 0 then
                report_setups("% t",valid)
            end
            context.bold("available setup groups: ")
            context("%, t.",valid)
        end
    elseif document.arguments.overview then
        if document.arguments.save then
            context.enablemode { "setups:save" }
        end
        context.input("x-setups-overview.mkiv")
    elseif #document.files > 0 then
        context.usemodule { "x-setups-basics" }
        for i=1,#document.files do
            local filename = "i-" .. document.files[i]
            report_setups("processing %a",filename)
            context.loadsetups { filename }
        end
        context.input("x-setups-proofing.mkiv")
    else
        context("no setups")
    end

    context.stoptext()
\stopluacode

\stoptext