Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stevedonovan/Penlight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authornathanrpage97 <33010515+nathanrpage97@users.noreply.github.com>2022-07-21 16:45:10 +0300
committerGitHub <noreply@github.com>2022-07-21 16:45:10 +0300
commit0f07534dd9096c0f21da14cd713d91094cf040ee (patch)
treed1d113621f9f728c449671ba226266cb2fc545f9 /lua
parentcc76e12ff298a34e5df282e522a75a26525f6906 (diff)
fix(lapp) add file name to arg table when using the default value (#427)
Co-authored-by: nathanrpage97 <nathanrpage97@gmail.com>
Diffstat (limited to 'lua')
-rw-r--r--lua/pl/lapp.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/lua/pl/lapp.lua b/lua/pl/lapp.lua
index 6c54592..d7ad062 100644
--- a/lua/pl/lapp.lua
+++ b/lua/pl/lapp.lua
@@ -246,6 +246,7 @@ function lapp.process_options_string(str,args)
line = res.rest
res = {}
local optional
+ local defval_str
-- do we have ([optional] [<type>] [default <val>])?
if match('$({def} $',line,res) or match('$({def}',line,res) then
local typespec = strip(res.def)
@@ -288,6 +289,7 @@ function lapp.process_options_string(str,args)
-- optional 'default value' clause. Type is inferred as
-- 'string' or 'number' if there's no explicit type
if default or match('default $r{rest}',typespec,res) then
+ defval_str = res.rest
defval,vtype = process_default(res.rest,vtype)
end
else -- must be a plain flag, no extra parameter required
@@ -297,6 +299,7 @@ function lapp.process_options_string(str,args)
local ps = {
type = vtype,
defval = defval,
+ defval_str = defval_str,
required = defval == nil and not optional,
comment = res.rest or optparm,
constraint = constraint,
@@ -426,6 +429,9 @@ function lapp.process_options_string(str,args)
if not ps.used then
if ps.required then lapp.error("missing required parameter: "..parm) end
set_result(ps,parm,ps.defval)
+ if builtin_types[ps.type] == "file" then
+ set_result(ps, parm .. "_name", ps.defval_str)
+ end
end
end
return results