From b821116421f0d942052ad225f4ea62aef2696817 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 13 Jul 2020 17:21:34 +0200 Subject: 2020-07-13 16:31:00 --- scripts/context/lua/mtx-kpse.lua | 90 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 scripts/context/lua/mtx-kpse.lua (limited to 'scripts/context/lua/mtx-kpse.lua') diff --git a/scripts/context/lua/mtx-kpse.lua b/scripts/context/lua/mtx-kpse.lua new file mode 100644 index 000000000..025dd5ff5 --- /dev/null +++ b/scripts/context/lua/mtx-kpse.lua @@ -0,0 +1,90 @@ +if not modules then modules = { } end modules ['mtx-kpse'] = { + version = 1.001, + comment = "companion to mtxrun.lua", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- I decided to make this module after a report on the mailing list about +-- a clash with texmf-var on a system that had texlive installed. One way +-- to figure that out is to use kpse. We had the code anyway. +-- +-- mtxrun --script kpse --progname=pdftex --findfile context.mkii + +trackers.enable("resolvers.lib.silent") + +local kpse = LUATEXENGINE == "luametatex" and require("libs-imp-kpse") + +if type(kpse) ~= "table" then + return +end + +local helpinfo = [[ + + + + mtx-kpse + ConTeXt KPSE checking utility + 1.00 + + + + + mandate, set the program name (e.g. pdftex) + report the fully qualified path of the given file + expand the given path variable + expand a variable + expand a complex variable specification + show the value of a variable + report if a file is readable + list all supported formats + + + only wipe fonts + + + + +]] + +local application = logs.application { + name = "mtx-kpse", + banner = "ConTeXt KPSE checking utility", + helpinfo = helpinfo, +} + +local report = application.report +local argument = environment.argument +local target = environment.files[1] + +if argument("progname") or argument("programname") then + kpse.set_program_name(argument("progname")) +else + application.help() + return +end + +if argument("exporthelp") then + application.export(environment.argument("exporthelp"),target) +elseif argument("filetypes") or argument("formats") then + print(table.concat(kpse.get_file_types()," ")) +elseif type(target) == "string" and target ~= "" then + if argument("findfile") or argument("find-file") then + print(kpse.find_file(target,argument("format"))) + elseif argument("expandpath") or argument("expand-path") then + print(kpse.expand_path(target)) + elseif argument("expandvar") or argument("expand-var") then + print(kpse.expand_var(target)) + elseif argument("expandbraces") or argument("expand-braces") then + print(kpse.expand_braces(target)) + elseif argument("varvalue") or argument("var-value") then + print(kpse.var_value(target)) + elseif argument("readablefile") or argument("readable-file") then + print(kpse.readable_file(target)) + else + application.help() + end +else + application.help() +end -- cgit v1.2.3