2

I have the following code

\startluacode
company = context.env("company")
patch_file = "public/" .. company .. "/patch-english.json"
\stopluacode

where I pass the company value via command line context --arguments=company=mycompany mydoc.tex

This does obviously not work. How can I get the variable from the command line into lua code?

1
  • It's in environment.arguments I believe. Jul 29, 2021 at 7:37

1 Answer 1

2

You can use environment.argument to query the command line arguments.

\starttext

\startluacode
company = environment.argument("company")
context("company = " .. company)
\stopluacode

\stoptext
context --company=mycompany test.tex

enter image description here

If you do not want to use Lua, you can try

\starttext

company = \env{company}

\stoptext
context --arguments=company=mycompany test.tex
4
  • 1
    Out of curiosity, is there a way to do it for general tex variables?
    – Reza
    Jul 30, 2021 at 9:08
  • Is this documented somewhere?
    – Reza
    Jul 30, 2021 at 9:09
  • @Reza What do you mean with “general tex variables”? You can of course use context --company='\def\company{mycompany}' test.tex if that is what you want. Documentation I don't know. I usually discover stuff by following the mailing list. Aug 1, 2021 at 13:35
  • @Reza I think I found what you were looking for. See updated answer. Aug 1, 2021 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .