I am trying to parse extra arguments given to lualatex in command line — e.g lualatex --jobname=out in.tex myarg.
Though I could not find it in the docs, I discovered from this answer that I can use the arg variable to access command line arguments. However, these give me all arguments given to lualatex, including options and input file.
Currently my code looks something like this:
function get_args()
arguments = {}
reached_doc_arguments = false
document_arg_position = -1
for index,argument in ipairs(arg) do
if reached_doc_arguments then
arguments[index - document_arg_position] = argument
elseif argument:match("%.tex$") then
document_arg_position = index
reached_doc_arguments = true
end
end
return arguments
end
However, this fails in cases where the .tex suffix is omited, and when options are given after the input file. I can't skip the first argument because options may be specified, and as mentioned, I can't use \jobname or status.filename.
I'm wondering if there is an intended, more complete way to do something like this?
--jobname out. The code will print the original filename as one of the arguments. – Atai Ambus Jul 08 '22 at 06:17--jobname=out, it works, but to make it work with a space instead of=you'd probably need to hardcode every option that can take an argument. – Max Chernoff Jul 08 '22 at 06:39