aboutsummaryrefslogblamecommitdiff
path: root/nerv/test/parse_args.lua
blob: 34ad55e864ae7c088bd18b43d84f78c384f88726 (plain) (tree)
1
2
3
4
5
6
7
8
9





                                                                                            

                                                              
 


                                                                    
 
                         
                                                 
local options = {{"abandon", "a", "boolean", default = false, desc = "abandon your belief"},
                 {"bullshit", "b", "boolean", default = false, desc = "start to bullshit"},
                 {"cheat", "c", "boolean", default = false, desc = "try to cheat"},
                 {"delete", "d", "boolean", default = false, desc = "remove everything"},
                 {"hehe", "h", "boolean", default = false, desc = "233333"},
                 {"oh", "o", "boolean", default = true, desc = "oh yes!"},
                 {"uid", nil, "int", desc = "user uid"},
                 {"str", nil, "string", desc = "test string"}}

args, opts = nerv.parse_args({"arg1", "arg2", "-abcd", "arg3",
                                "--hehe", "--oh=no", "--uid=43",
                                "highfive", "--str=hello"}, options)

nerv.print_usage(options)
print(table.tostring(args), table.tostring(opts))