Software /
code /
prosody
Comparison
tools/migration/prosody-migrator.lua @ 7894:217412da818f
migrator: Fix argument parsing
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 15 Feb 2017 15:30:19 +0100 |
parent | 7893:432f721b0fdf |
child | 7895:1e1c18012048 |
comparison
equal
deleted
inserted
replaced
7893:432f721b0fdf | 7894:217412da818f |
---|---|
14 | 14 |
15 local default_config = (CFG_CONFIGDIR or ".").."/migrator.cfg.lua"; | 15 local default_config = (CFG_CONFIGDIR or ".").."/migrator.cfg.lua"; |
16 | 16 |
17 -- Command-line parsing | 17 -- Command-line parsing |
18 local options = {}; | 18 local options = {}; |
19 local handled_opts = 0; | 19 local i = 1; |
20 for i = 1, #arg do | 20 while arg[i] do |
21 if arg[i]:sub(1,2) == "--" then | 21 if arg[i]:sub(1,2) == "--" then |
22 local opt, val = arg[i]:match("([%w-]+)=?(.*)"); | 22 local opt, val = arg[i]:match("([%w-]+)=?(.*)"); |
23 if opt then | 23 if opt then |
24 options[(opt:sub(3):gsub("%-", "_"))] = #val > 0 and val or true; | 24 options[(opt:sub(3):gsub("%-", "_"))] = #val > 0 and val or true; |
25 end | 25 end |
26 handled_opts = i; | 26 table.remove(arg, i); |
27 else | 27 else |
28 break; | 28 i = i + 1; |
29 end | 29 end |
30 end | 30 end |
31 table.remove(arg, handled_opts); | |
32 | 31 |
33 if CFG_SOURCEDIR then | 32 if CFG_SOURCEDIR then |
34 package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; | 33 package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; |
35 package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath; | 34 package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath; |
36 else | 35 else |