1if not modules then modules = { } end modules ['mtx-base'] = {
2 version = 1.001,
3 comment = "formerly known as luatools",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local helpinfo = [[
10<?xml version="1.0"?>
11<application>
12 <metadata>
13 <entry name="name">mtx-base</entry>
14 <entry name="detail">ConTeXt TDS Management Tool (aka luatools)</entry>
15 <entry name="version">1.35</entry>
16 </metadata>
17 <flags>
18 <category name="basic">
19 <subcategory>
20 <flag name="generate"><short>generate file database</short></flag>
21 <flag name="variables"><short>show configuration variables</short></flag>
22 <flag name="configurations"><short>show configuration order</short></flag>
23 <flag name="expand-braces"><short>expand complex variable</short></flag>
24 <flag name="expand-path"><short>expand variable (resolve paths)</short></flag>
25 <flag name="expand-var"><short>expand variable (resolve references)</short></flag>
26 <flag name="show-path"><short>show path expansion of ...</short></flag>
27 <flag name="var-value"><short>report value of variable</short></flag>
28 <flag name="find-file"><short>report file location</short></flag>
29 <flag name="find-path"><short>report path of file</short></flag>
30 <flag name="make"><short>[or <ref name="ini"/>] make luatex format</short></flag>
31 <flag name="run"><short>[or <ref name="fmt"/>] run luatex format</short></flag>
32 <flag name="compile"><short>assemble and compile lua inifile</short></flag>
33 <flag name="verbose"><short>give a bit more info</short></flag>
34 <flag name="all"><short>show all found files</short></flag>
35 <flag name="format" value="str"><short>filter cf format specification (default 'tex', use 'any' for any match)</short></flag>
36 <flag name="pattern" value="str"><short>filter variables</short></flag>
37 <flag name="trackers" value="list"><short>enable given trackers</short></flag>
38 </subcategory>
39 </category>
40 </flags>
41</application>
42]]
43
44local application = logs.application {
45 name = "mtx-base",
46 banner = "ConTeXt TDS Management Tool (aka luatools) 1.35",
47 helpinfo = helpinfo,
48}
49
50local report = application.report
51
52
53
54local pattern = environment.arguments["pattern"] or nil
55local fileformat = environment.arguments["format"] or ""
56local allresults = environment.arguments["all"] or false
57local trace = environment.arguments["trace"]
58
59if type(pattern) == 'boolean' then
60 report("invalid pattern specification")
61 pattern = nil
62end
63
64if trace then
65 resolvers.settrace(trace)
66end
67
68if environment.arguments["find-file"] then
69 resolvers.load()
70 if pattern then
71 resolvers.dowithfilesandreport(resolvers.findfiles, { pattern }, fileformat, allresults)
72 else
73 resolvers.dowithfilesandreport(resolvers.findfiles, environment.files, fileformat, allresults)
74 end
75elseif environment.arguments["find-path"] then
76 resolvers.load()
77 local path = resolvers.findpath(environment.files[1], fileformat)
78 print(path)
79elseif environment.arguments["expand-braces"] then
80 resolvers.load("nofiles")
81 resolvers.dowithfilesandreport(resolvers.expandbraces, environment.files)
82elseif environment.arguments["expand-path"] then
83 resolvers.load("nofiles")
84 resolvers.dowithfilesandreport(resolvers.expandpath, environment.files)
85elseif environment.arguments["expand-var"] or environment.arguments["expand-variable"] then
86 resolvers.load("nofiles")
87 resolvers.dowithfilesandreport(resolvers.expansion, environment.files)
88elseif environment.arguments["show-path"] or environment.arguments["path-value"] then
89 resolvers.load("nofiles")
90 resolvers.dowithfilesandreport(resolvers.showpath, environment.files)
91elseif environment.arguments["var-value"] or environment.arguments["show-value"] then
92 resolvers.load("nofiles")
93 resolvers.dowithfilesandreport(resolvers.variable, environment.files)
94elseif environment.arguments["format-path"] then
95 resolvers.load()
96 report(caches.getwritablepath("format"))
97elseif pattern then
98 resolvers.load()
99 resolvers.dowithfilesandreport(resolvers.findfiles, { pattern }, fileformat, allresults)
100elseif environment.arguments["generate"] then
101 resolvers.renewcache()
102 trackers.enable("resolvers.locating")
103 resolvers.load()
104elseif environment.arguments["make"] or environment.arguments["ini"] or environment.arguments["compile"] then
105 resolvers.load()
106 trackers.enable("resolvers.locating")
107 environment.make_format(environment.files[1] or "")
108elseif environment.arguments["variables"] or environment.arguments["show-variables"] or environment.arguments["expansions"] or environment.arguments["show-expansions"] then
109 resolvers.load("nofiles")
110 resolvers.listers.variables(pattern)
111elseif environment.arguments["configurations"] or environment.arguments["show-configurations"] then
112 resolvers.load("nofiles")
113 resolvers.listers.configurations()
114elseif environment.arguments["exporthelp"] then
115 application.export(environment.arguments["exporthelp"],environment.files[1])
116elseif environment.arguments["help"] or (environment.files[1]=='help') or (#environment.files==0) then
117 application.help()
118elseif environment.files[1] == 'texmfcnf.lua' then
119 resolvers.load("nofiles")
120 resolvers.listers.configurations()
121else
122 resolvers.load()
123 resolvers.dowithfilesandreport(resolvers.findfiles, environment.files, fileformat, allresults)
124end
125 |