From 42608086c666e23ceac0e9046836a8fefe00e5b2 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 2 Mar 2016 14:27:07 +0800 Subject: add `nerv.print_usage(options)` --- nerv/test/parse_args.lua | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'nerv/test') diff --git a/nerv/test/parse_args.lua b/nerv/test/parse_args.lua index 7146c3b..0d280a1 100644 --- a/nerv/test/parse_args.lua +++ b/nerv/test/parse_args.lua @@ -1,16 +1,15 @@ -args, opts = nerv.parse_args( - {"arg1", "arg2", "-abcd", "arg3", - "--hehe", "--oh=no", "--uid=43", - "highfive", "--str=hello"}, +local options = {{"abandon", "a", "bool", default = false, desc = "abandon your belief"}, + {"bullshit", "b", "bool", default = false, desc = "start to bullshit"}, + {"cheat", "c", "bool", default = false, desc = "try to cheat"}, + {"delete", "d", "bool", default = false, desc = "remove everything"}, + {"hehe", "h", "bool", default = false, desc = "233333"}, + {"oh", "o", "bool", default = true, desc = "oh yes!"}, + {"uid", nil, "int", desc = "user uid"}, + {"str", nil, "string", desc = "test string"}} - {{"abandon", "a", "bool", default = false, desc = "abandon your belief"}, - {"bullshit", "b", "bool", default = false, desc = "start to bullshit"}, - {"cheat", "c", "bool", default = false, desc = "try to cheat"}, - {"delete", "d", "bool", default = false, desc = "remove everything"}, - {"hehe", "h", "bool", default = false, desc = "233333"}, - {"oh", "o", "bool", 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)) -- cgit v1.2.3