Software /
code /
clix
Diff
clix.lua @ 131:58d485001448
clix: Use tabs for indentation in command line parsing
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 14 Nov 2020 15:26:06 +0100 |
parent | 127:6a27edf256c3 |
child | 165:e4391832be1e |
line wrap: on
line diff
--- a/clix.lua Sat Aug 25 00:19:51 2018 +0200 +++ b/clix.lua Sat Nov 14 15:26:06 2020 +0100 @@ -143,22 +143,22 @@ local command, args_handled_up_to; for i, opt in ipairs(arg) do - if opt:match("^%-") and opt ~= "--" then - local name = opt:match("^%-%-?([^%s=]+)()") - name = (short_opts[name] or name):gsub("%-+", "_"); - if name:match("^no_") then - name = name:sub(4, -1); - opts[name] = false; - else - opts[name] = opt:match("=(.*)$") or true; - end - elseif not command then - command = arg[i]; - args_handled_up_to = i-1; - else - args_handled_up_to = i-1; - break; - end + if opt:match("^%-") and opt ~= "--" then + local name = opt:match("^%-%-?([^%s=]+)()") + name = (short_opts[name] or name):gsub("%-+", "_"); + if name:match("^no_") then + name = name:sub(4, -1); + opts[name] = false; + else + opts[name] = opt:match("=(.*)$") or true; + end + elseif not command then + command = arg[i]; + args_handled_up_to = i-1; + else + args_handled_up_to = i-1; + break; + end end -- Remove all the handled args from the arg array