recover_pk.py: replace secp192r1 by prime192v1
[RRG-proxmark3.git] / client / luascripts / examples / example_parameters.lua
blob0925f7d2cdcfad24ea1091db0fbf7b081b182376
1 -- The getopt-functionality is loaded from pm3/getopt.lua
2 -- Have a look there for further details
3 local getopt = require('getopt')
4 local ansicolors = require('ansicolors')
6 copyright = ''
7 usage = 'script run example_parameters.lua -a 1 -blala -c -de'
8 author = 'Martin Holst Swende'
9 version = 'v1.0.2'
10 desc = [[
11 This is an example script to demonstrate handle parameters in scripts.
12 For more info, check the comments in the code
14 example = [[
15 1. script run example_parameters -a mytestparam_input -c
17 usage = [[
18 script run example_parameters [-h] [-a <txt>] [-b <txt>] [-c] [-d] [-e]
20 arguments = [[
21 -h This help
22 -a <txt> text
23 -b <txt> text
24 -c test param w/o input
25 -d test param w/o input
26 -e test param w/o input
29 ---
30 -- Usage help
31 local function help()
32 print(copyright)
33 print(author)
34 print(version)
35 print(desc)
36 print(ansicolors.cyan..'Usage'..ansicolors.reset)
37 print(usage)
38 print(ansicolors.cyan..'Arguments'..ansicolors.reset)
39 print(arguments)
40 print(ansicolors.cyan..'Example usage'..ansicolors.reset)
41 print(example)
42 end
44 local function main(args)
46 print('These parameters were passed')
47 --[[
48 When passing parameters,
49 x: means that a value should follow x
50 y means that 'y' is a flag, either on or off
51 So, the string a:b:def means that we support up to
52 5 parameters; two with values and three flags. The following
53 should be valid:
55 script run example_parameters.lua -a 1 -blala -c -de
57 Notice two things:
58 1. 'blala' works just like 'b lala', both set 'b' to 'lala'
59 2. Flags can be put together, '-de' is the same as '-d -e'
60 3. The format -b=lala is *not* supported
61 4. The format b lala (without -) is *not* supported
62 --]]
64 for o, a in getopt.getopt(args, 'ha:b:ced') do
65 if o == 'h' then return help() end
66 print(o, a)
67 end
68 end
71 --[[
72 In the future, we may implement so that scripts are invoked directly
73 into a 'main' function, instead of being executed blindly. For future
74 compatibility, I have done so, but I invoke my main from here.
75 --]]
76 main(args)