How to pass and read arguments to a lua program?

lua

Solution

Command line arguments are in the global table `arg`. See here for details. Since there is no argparse/optparse library you will need to handle the logic for short and long switches yourself.

Problem

Equivalent to `main(int argc, char*argv[])` of C. For example: `./foo.lua -a -b` how do I read `-a` and `-b` from `foo.lua` program?

Original source