[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: More complete std.optparse example?
- From: gary@...
- Date: Thu, 28 Apr 2016 07:01:05 +0100
Hi Dan,
Thanks for your interest in the project!
The content of arg and opts depends on what you wrote in help :-)
You can explore what happens by adding this code:
for k,v in pairs (opts) do print ("opts['" .. tostring(k) .. "']", v) end
for i,v in ipairs (arg) do print ("arg[" .. i .. "]", v) end
And then running your program with various options to see what happens.
You can also see a more complex example in specl, taking help from:
https://github.com/gvvaughan/specl/blob/master/lib/specl/version.lua
And parsing in process_args() from:
https://github.com/gvvaughan/specl/blob/master/lib/specl/main.lua
HTH,
--
Gary V. Vaughan (gary AT vaughan DOT pe)
On 28 Apr 2016, 02:13 +0100, Dan Christian <danchristian65@gmail.com>, wrote:
I'm trying to use std.optparse for the first time. The example shows
me how to get a parse arg and opt, but I don't know how to test
individual options from there.
local parser = OptionParser (help)
local arg, opts = parser:parse (_G.arg)
...
What should ... be?
Thanks,
Dan