Skip to content

Commit aba1750

Browse files
committed
use new argparse functions
1 parent 1220f66 commit aba1750

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

plugins/lua/tiletypes.lua

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
local _ENV = mkmodule('plugins.tiletypes')
22

3+
local argparse = require('argparse')
34
local utils = require('utils')
45

56
local function parse_cursor(opts, arg)
6-
local _, _, x, y, z = arg:find('^%s*(%d+)%s*,%s*(%d+)%s*,%s*(%d+)%s*$')
7-
if not x then
8-
qerror(('invalid argument for --cursor option: "%s"; expected format' ..
9-
' is "<x>,<y>,<z>", for example: "30,60,150"'):format(arg))
10-
end
11-
opts.cursor.x = tonumber(x)
12-
opts.cursor.y = tonumber(y)
13-
opts.cursor.z = tonumber(z)
7+
utils.assign(opt.cursor, argparse.coords(arg))
148
end
159

1610
function parse_commandline(opts, ...)
17-
local positionals = utils.processArgsGetopt({...}, {
11+
local positionals = argparse.processArgsGetopt({...}, {
1812
{'c', 'cursor', hasArg=true,
1913
handler=function(arg) parse_cursor(opts, arg) end},
2014
{'h', 'help', handler=function() opts.help = true end},

0 commit comments

Comments
 (0)