diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-24 14:13:32 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-24 19:56:05 +0100 |
commit | bb638f7c7d851f20071f5f9ee77224c0173e73ae (patch) | |
tree | 25e5dd540a9064e1c189ad17e1c76ef2027db05a /lualib/rspamadm/getopt.lua | |
parent | 08e99bfde4713e6253ce705926851c6639f65437 (diff) | |
download | rspamd-bb638f7c7d851f20071f5f9ee77224c0173e73ae.tar.gz rspamd-bb638f7c7d851f20071f5f9ee77224c0173e73ae.zip |
[Project] Move rspamadm libraries to a standard place
Diffstat (limited to 'lualib/rspamadm/getopt.lua')
-rw-r--r-- | lualib/rspamadm/getopt.lua | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/lualib/rspamadm/getopt.lua b/lualib/rspamadm/getopt.lua deleted file mode 100644 index 20715c387..000000000 --- a/lualib/rspamadm/getopt.lua +++ /dev/null @@ -1,50 +0,0 @@ -local function insert_option(tab, name, value) - if tab[name] then - if type(tab[name]) == 'table' then - table.insert(tab[name], value) - else - local old_val = tab[name] - tab[name] = { - old_val, - value - } - end - else - tab[name] = value - end -end - -local function getopt(arg, options) - local tab = {} - for k, v in ipairs(arg) do - if string.sub(v, 1, 2) == "--" then - local x = string.find(v, "=", 1, true) - if x then insert_option(tab, string.sub(v, 3, x - 1), string.sub(v, x + 1)) - else tab[string.sub(v, 3)] = true - end - elseif string.sub(v, 1, 1) == "-" then - local y = 2 - local l = string.len(v) - local jopt - while (y <= l) do - jopt = string.sub(v, y, y) - if string.find(options, jopt, 1, true) then - if y < l then - insert_option(tab, jopt, string.sub(v, y + 1)) - y = l - else - insert_option(tab, jopt, arg[k + 1]) - end - else - tab[jopt] = true - end - y = y + 1 - end - end - end - return tab -end - -return { - getopt = getopt -} |