summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-28 02:17:40 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-28 02:17:40 +0000
commit91ccdf750ab86749a6465f30c153a01d40ea0339 (patch)
tree4040cc242837790601667302869a1fcf4db1bb23 /Master
parent3ca03e8c6e771a2373eb92e98e454bef0e24144a (diff)
adding a -i/-I config option, and cleaning up a few details or typo in options
git-svn-id: svn://tug.org/texlive/trunk@9833 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf/scripts/texlive/texdoc.tlu89
1 files changed, 55 insertions, 34 deletions
diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu
index 4a8bb5f0efc..51483361090 100755
--- a/Master/texmf/scripts/texlive/texdoc.tlu
+++ b/Master/texmf/scripts/texlive/texdoc.tlu
@@ -30,19 +30,22 @@ Public domain.]]
-- some constants
progname = 'texdoc'
version = '0.4beta'
--- make sure to update usage_msg along with setup_config_from_cl() below
+-- make sure to update setup_config_from_cl() and the man page accordingly
+-- and set a default value in setup_config_from_defaults() if relevant
usage_msg = [[
-Usage: texdoc -h, --help | -V, --version | [option] name(s)
- -h|--help Show this help.
- -V|--version Print the version of the program.
- -v|--verbose Show the command being used to display the documentation.
- -a|--alias Use the alias table.
- -A|--noalias Don't use the alias table.
- -e|--extension Search only for files of given type (extension).
- -w|--view Use view mode: start a viewer.
- -m|--mixed Use mixed mode (view or list).
- -l|--list Use list mode: don't start a viewer.
- -s|--search Search for name as a substring.
+Usage: texdoc -h, --help | -V, --version | [option(s)] name(s)
+ -h|--help Show this help.
+ -V|--version Print the version of the program.
+ -v|--verbose Show the command used to display the documentation.
+ -i|--interactive Force interactive menus.
+ -I|--nointeractive Force non-interactive menus (lists).
+ -a|--alias Use the alias table.
+ -A|--noalias Don't use the alias table.
+ -e|--extension Search only for files of given type (extension).
+ -w|--view Use view mode: start a viewer.
+ -m|--mixed Use mixed mode (view or list).
+ -l|--list Use list mode: don't start a viewer.
+ -s|--search Search for name as a substring.
Typing `texdoc texdoc' gives you the complete manual.]]
notfound_msg = [[
Sorry, no documentation found for PKGNAME.
@@ -256,8 +259,10 @@ function set_alias (key, value)
end
-- set config from the command line
+-- Please make sure to update usage_msg and the man page accordingly
+-- and set a default value in setup_config_from_defaults() if relevant.
function setup_config_from_cl ()
- while table.maxn(arg) > 0 and string.match(arg[1],'^%-') do
+ while arg[1] and string.match(arg[1],'^%-') do
curr_arg = table.remove(arg,1)
if (curr_arg == '-h') or (curr_arg == '--help') then
print (usage_msg)
@@ -275,14 +280,20 @@ function setup_config_from_cl ()
set_config_element('mode', 'list')
elseif (curr_arg == '-s') or (curr_arg == '--search') then
set_config_list { mode = 'search', enable_alias = 'false'}
- elseif (curr_arg == '-A') or (curr_arg == '--alias') then
+ elseif (curr_arg == '-I') or (curr_arg == '--nointeractive') then
+ set_config_element('interactive', 'false')
+ elseif (curr_arg == '-i') or (curr_arg == '--interactive') then
+ set_config_element('interactive', 'true')
+ elseif (curr_arg == '-A') or (curr_arg == '--noalias') then
set_config_element('enable_alias', 'false')
- elseif (curr_arg == '-a') or (curr_arg == '--noalias') then
+ elseif (curr_arg == '-a') or (curr_arg == '--alias') then
set_config_element('enable_alias', 'true')
- elseif string.match(curr_arg, '^-t') then
- set_config_element('ext_list', string.gsub(curr_arg, '^-t=?', ''))
- elseif string.match(curr_arg, '^--type') then
- set_config_element('ext_list', string.gsub(curr_arg, '^--type=?', ''))
+ elseif string.match(curr_arg, '^-e') then
+ set_config_element('ext_list',
+ string.gsub(curr_arg, '^-e=?', ''))
+ elseif string.match(curr_arg, '^--extension') then
+ set_config_element('ext_list',
+ string.gsub(curr_arg, '^--extension=?', ''))
else
print ("texdoc error: unknow option: "..curr_arg)
end
@@ -446,6 +457,7 @@ function setup_config_from_defaults()
mode = 'view',
enable_alias = 'true', -- string, not boolean
verbose = 'true',
+ interactive = 'true',
}
-- now a particular case for config.ext_list and zip-related stuff
-- Note: removed texdoc_formats/zip_formats, gives simpler & generic code
@@ -591,7 +603,11 @@ function display_table (t, offset)
offset = offset or 0
table.sort(t, file_order)
for i, val in ipairs (t) do
- print (i+offset, real_path(val))
+ if interactive then
+ print (i+offset, real_path(val))
+ else
+ print (real_path(val))
+ end
end
end
@@ -599,22 +615,26 @@ end
function print_menu (files, comp)
comp = comp or {}
local f = #files
- local n = f + #comp
- if n > 20 then
- io.write (n, "results. Display them all? (y/N) ")
- local ans = io.read(1)
- if not ((ans == 'y') or (ans == 'Y')) then return end
+ if interactive then
+ local n = f + #comp
+ if n > 20 then
+ io.write (n, "results. Display them all? (y/N) ")
+ local ans = io.read(1)
+ if not ((ans == 'y') or (ans == 'Y')) then return end
+ end
end
display_table (files)
display_table (comp, f)
- io.write ("Please enter the number of the file to view, or 0 to exit: ")
- local num = io.read('*number')
- if num and (num <= #files) and files[num] then
- print ("Viewing file '"..files[num].."'.")
- elseif num and comp[num-f] then
- print ("Viewing file '"..comp[num-f].."'.")
- elseif num ~= 0 then
- print ("Incorrect input, skipping.")
+ if interactive then
+ io.write ("Please enter the number of the file to view, or 0 to exit: ")
+ local num = io.read('*number')
+ if num and (num <= #files) and files[num] then
+ print ("Viewing file '"..files[num].."'.")
+ elseif num and comp[num-f] then
+ print ("Viewing file '"..comp[num-f].."'.")
+ elseif num ~= 0 then
+ print ("Incorrect input, skipping.")
+ end
end
end
@@ -668,9 +688,10 @@ setup_config_from_env ()
setup_config_from_files ()
setup_config_from_defaults ()
--- shortcuts for boolean config option
+-- shortcuts for boolean config option (not very nice, but)
enable_alias = (config.enable_alias == 'true')
verbose = (config.verbose == 'true')
+interactive = (config.interactive == 'true')
-- we want an empty string for ext at the beginning, so that it works to specify
-- the complete filename (at least in list or view mode). Doesn't matter when