summaryrefslogtreecommitdiff
path: root/Master/texmf/scripts/texdoc/main.tlu
blob: cb105eabda3b4a1899981d26845cbd2bc5796f21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- texdoc's main()
--[[ 
Copyright 2008, 2009 Manuel Pégourié-Gonnard
Distributed under the terms of the GNU GPL version 3 or later.
See texdoc.tlu for details.
--]]

local L = {}
load_env(L, {
    'os',
    'print', 'ipairs',
    'arg',
    'C',
    'setup_config_and_alias',
    'get_doclist',
    'deliver_results',
})

-- setup config options and aliases from various places
setup_config_and_alias(arg)

-- make sure we actually have argument(s)
if not arg[1] then
    print(C.usage_msg)
    os.exit(C.exit_usage)
end

-- main loop
local docname
for _, docname in ipairs(arg) do
    -- do we have more then one argument?
    local multiarg = not not arg[2]
    -- get results
    local doclist = get_doclist(docname)
    -- deliver results to the user
    deliver_results(docname, doclist, multiarg)
end