Skip to content

Commit 4bd5bec

Browse files
authored
Create cleaners.lua
1 parent 86f98b0 commit 4bd5bec

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

plugins/lua/cleaners.lua

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
local _ENV = mkmodule('plugins.cleaners')
2+
3+
local argparse = require('argparse')
4+
local utils = require('utils')
5+
6+
function parse_commandline(opts, pos_1, pos_2, args)
7+
local positionals = argparse.processArgsGetopt(args,
8+
{
9+
{'a', 'all', handler=function()
10+
opts.map = true
11+
opts.units = true
12+
opts.items = true
13+
opts.plants = true end},
14+
{'m', 'map', handler=function() opts.map = true end},
15+
{'d', 'mud', handler=function() opts.mud = true end},
16+
{'s', 'snow', handler=function() opts.snow = true end},
17+
{'t', 'item', handler=function() opts.item_spat = true end},
18+
{'g', 'grass', handler=function() opts.grass = true end},
19+
{'x', 'desolate', handler=function() opts.desolate = true end},
20+
{'o', 'only', handler=function() opts.only = true end},
21+
{'u', 'units', handler=function() opts.units = true end},
22+
{'i', 'items', handler=function() opts.items = true end},
23+
{'z', 'zlevel', handler=function() opts.zlevel = true end},
24+
})
25+
26+
if #positionals > 2 then
27+
qerror('Too many positionals!')
28+
end
29+
30+
if positionals[1] then
31+
utils.assign(pos_1, argparse.coords(positionals[1], 'pos_1', true))
32+
end
33+
34+
if positionals[2] then
35+
utils.assign(pos_2, argparse.coords(positionals[2], 'pos_2', true))
36+
end
37+
end
38+
39+
return _ENV

0 commit comments

Comments
 (0)