2 -- The getopt-functionality is loaded from pm3/getopt.lua
3 -- Have a look there for further details
4 getopt
= require('getopt')
6 usage
= "script run parameters.lua -a 1 -blala -c -de"
7 author
= "Martin Holst Swende"
9 This is an example script to demonstrate handle parameters in scripts.
10 For more info, check the comments in the code
13 local function main(args
)
16 print("These parameters were passed")
18 When passing parameters,
19 x: means that a value should follow x
20 y means that 'y' is a flag, either on or off
21 So, the string a:b:def means that we support up to
22 5 parameters; two with values and three flags. The following
25 script run parameters.lua -a 1 -blala -c -de
28 1. 'blala' works just like 'b lala', both set 'b' to 'lala'
29 2. Flags can be put together, '-de' is the same as '-d -e'
30 3. The format -b=lala is *not* supported
31 4. The format b lala (without -) is *not* supported
34 for o
, a
in getopt
.getopt(args
, 'a:b:ced') do
41 In the future, we may implement so that scripts are invoked directly
42 into a 'main' function, instead of being executed blindly. For future
43 compatibility, I have done so, but I invoke my main from here.