CLI Variable Input

Saklad5

Member
Is it possible to run a script with multiple input variables without using the dialog box to enter values each time? I’ve been trying to run Veracity’s MMG script without having to type numbers manually each run, but it will only set the first variable in main. Any other numbers in the CLI are disregarded.

For example, “mmg2 2000” and “mmg2 2000 2 5 5” will do the exact same thing, asking for the last three int variables it needs to run.

Am I missing something, or is this a real limitation of KoLmafia? Do I have to rewrite the script to accept one variable and extract four values from it to get this to behave that way?
 

Veracity

Developer
Staff member
Try "mmg2 (2000,2,5,5)".

Note the space between the script name and the parenthesized list of comma-separated arguments.
 

Saklad5

Member
Thank you, that’s exactly what I was looking for.

The syntax is rather bizarre, though. Is that documented anywhere I missed?
 

Veracity

Developer
Staff member
I wouldn't know. I looked at the source code. Who reads documentation? ;)

It would be less bizarre, to my eye, if you didn't need that space. It would then, essentially, look like a call to the main() function of the specified script.
 

xKiv

Active member
I believe it's because CLI does word splitting first, so "mmg(2000,2,2,5)" would be trying to call a script or macro *named* "mmg(2000,2,2,5)" (with no parameters)?
 

lostcalpolydude

Developer
Staff member
It seems reasonable to decide that script names are not allowed to have parentheses in them (I don't recall ever seeing a script name with parentheses, so probably no one would notice), and to adjust parsing appropriately. If someone was motivated enough to make that change.
 

Saklad5

Member
I sort of just assume everything uses POSIX shell syntax until I learn otherwise. If you want to change the syntax, I recommend using that as a model.
 

Saklad5

Member
Of course. I’m just saying that if you are going to change it anyway, you should change it to match the POSIX shell.

How exactly do aliases work, anyway? Would they be incompatible?
 

xKiv

Active member
I think X => Y just does a .replaceAll("X","Y"), everywhere on the line, even in the middle of words. This is why using "parametrized" aliases is recommended: if you use %% in the replacement, mafia will only replace X at the beginning of a line.
 
Top