From 04fdaba85854140264ce787142d52455a99e4764 Mon Sep 17 00:00:00 2001 From: dvs1 Date: Mon, 4 Nov 2024 15:55:12 +1000 Subject: Pass name to option funcs, and use it in help command. --- PolygLua.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PolygLua.lua b/PolygLua.lua index 77f01f4..17abd88 100755 --- a/PolygLua.lua +++ b/PolygLua.lua @@ -41,8 +41,8 @@ _G.C = function(s) log(-1, 'CRITICAL ', s) end local optionsCommon = { help = {help = 'Print the help text.', - func = function(self, options, a, args, i) - for i,v in ipairs{'/usr/share/doc/', '/usr/local/share/doc/', './'} do + func = function(self, options, a, args, i, name) + for i,v in ipairs{'/usr/share/doc/' .. name, '/usr/local/share/doc/' .. name, './'} do local p = v .. 'README.md' local h = io.open(p, 'r') if nil ~= h then @@ -108,7 +108,7 @@ _.parse = function(args, options, name) if nil == o then o = optionsCommon[name] end if nil ~= o then if nil ~= val then o.value = val; D(name .. ' = ' .. tostring(val)) end - if nil ~= o.func then o:func(options, a, args, i) end + if nil ~= o.func then o:func(options, a, args, i, name) end end return o end -- cgit v1.1