use new argparse functions

develop
myk002 2021-07-03 16:19:42 -07:00
parent 1220f6692c
commit aba1750bac
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 3 additions and 9 deletions

@ -1,20 +1,14 @@
local _ENV = mkmodule('plugins.tiletypes')
local argparse = require('argparse')
local utils = require('utils')
local function parse_cursor(opts, arg)
local _, _, x, y, z = arg:find('^%s*(%d+)%s*,%s*(%d+)%s*,%s*(%d+)%s*$')
if not x then
qerror(('invalid argument for --cursor option: "%s"; expected format' ..
' is "<x>,<y>,<z>", for example: "30,60,150"'):format(arg))
end
opts.cursor.x = tonumber(x)
opts.cursor.y = tonumber(y)
opts.cursor.z = tonumber(z)
utils.assign(opt.cursor, argparse.coords(arg))
end
function parse_commandline(opts, ...)
local positionals = utils.processArgsGetopt({...}, {
local positionals = argparse.processArgsGetopt({...}, {
{'c', 'cursor', hasArg=true,
handler=function(arg) parse_cursor(opts, arg) end},
{'h', 'help', handler=function() opts.help = true end},