aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ClientHamr/GuiLua/skang.lua123
1 files changed, 70 insertions, 53 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua
index 0f1285a..b6ac4e4 100644
--- a/ClientHamr/GuiLua/skang.lua
+++ b/ClientHamr/GuiLua/skang.lua
@@ -178,16 +178,11 @@ boolean, value beginning with T, t, F, f, etc is true, otherwise value is false,
178next token starts with an introducer, then value is true. 178next token starts with an introducer, then value is true.
179 179
180TODO - Finish supporting all of the above. 180TODO - Finish supporting all of the above.
181 -ab - Perhaps check for single character aliases, and if one matches, replace '-ab' with '-b'. 181 These all need deeper parsing, but we dunno if they might have been inside quoted strings from the shell.
182 If a match is found, and there's letters left, DON'T mark it as used. 182 arg=value Shell.
183 If it was the last one that was replaced, then check if there's a value after it. 183 arg1=value1&arg2=value2 For URLs.
184 These all need deeper parsing, but we dunno if they might have been inside quoted strings from the shell. 184 arg1=value1|arg2=value2 Can't remember why, probably the old skang multivalue syntax.
185 arg=value 185 Test it all.
186 arg = value
187 arg1=value1&arg2=value2
188 arg1=value1|arg2=value2
189 On the other hand,
190 --arg = value -> --arg value
191]] 186]]
192 187
193ARGS = {} 188ARGS = {}
@@ -213,6 +208,51 @@ scanArguments = function (args)
213 end 208 end
214end 209end
215 210
211parseType = function (module, thingy, v, value)
212 if 'string' == thingy.types[1] then
213 if value then
214 module[v[2] ] = value[2]
215 value[2] = nil -- Mark it as used.
216 else
217 print('ERROR - Expected a string value for ' .. thingy.names[1])
218 end
219 end
220
221 if 'number' == thingy.types[1] then
222 if value then
223 -- If the introducer is '-', then this should be a negative number.
224 if '-' == value[1] then value[1] = ''; value[2] = '-' .. value[2] end
225 -- Only parse the next value as a number if it doesn't have an introducer.
226 if ('' == value[1]) or ('=' == value[1]) then
227 value[2] = tonumber(value[2])
228 if value[2] then
229 module[v[2] ] = value[2]
230 value[2] = nil -- Mark it as used.
231 else
232 print('ERROR - Expected a number value for ' .. thingy.names[1])
233 end
234 else
235 module[v[2] ] = module[v[2] ] + 1
236 end
237 else
238 print('ERROR - Expected a number value for ' .. thingy.names[1])
239 end
240 end
241
242 if 'boolean' == thingy.types[1] then
243 if value then
244 -- Only parse the next value as a boolean if it doesn't have an introducer.
245 if ('' == value[1]) or ('=' == value[1]) then
246 module[v[2] ] = isBoolean(value[2])
247 value[2] = nil -- Mark it as used.
248 else
249 module[v[2] ] = true
250 end
251 else
252 print('ERROR - Expected a boolean value for ' .. thingy.names[1])
253 end
254 end
255end
216 256
217-- Restore the environment, and grab paramateres from standard places. 257-- Restore the environment, and grab paramateres from standard places.
218moduleEnd = function (module) 258moduleEnd = function (module)
@@ -231,53 +271,30 @@ moduleEnd = function (module)
231 local thingy = metaMum.__self.stuff[v[2] ] 271 local thingy = metaMum.__self.stuff[v[2] ]
232 -- Did we find one of ours? 272 -- Did we find one of ours?
233 if thingy then 273 if thingy then
234 local value = ARGS[i + 1] 274 parseType(module, thingy, v, ARGS[i + 1])
235 275 v[2] = nil -- Mark it as used.
236 if 'string' == thingy.types[1] then 276 else
237 if value then 277 -- Didn't find one directly, check for single letter matches in '-abc'.
238 module[v[2] ] = value[2] 278 for k, w in pairs(metaMum.__self.stuff) do
239 value[2] = nil -- Mark it as used. 279 if 1 == #w.names[1] then
240 else 280 for j = 1, #v[2] do
241 print('ERROR - Expected a string value for ' .. thingy.names[1]) 281 if string.sub(v[2], j, 1) == w.names[1] then
242 end 282 if 1 == j then
243 end 283 v[2] = string.sub(v[2], 2, -1)
244 284 if 'boolean' == w.types[1] then module[v[2] ] = true end
245 if 'number' == thingy.types[1] then 285 elseif #v[2] == j then
246 if value then 286 v[2] = string.sub(v[2], 1, j - 1)
247 -- If the introducer is '-', then this should be a negative number. 287 -- The one at the end is the only one that could have a following value.
248 if '-' == value[1] then value[1] = ''; value[2] = '-' .. value[2] end 288 parseType(module, w, v, ARGS[i + 1])
249 -- Only parse the next value as a number if it doesn't have an introducer. 289 else
250 if ('' == value[1]) or ('=' == value[1]) then 290 v[2] = string.sub(v[2], 1, j - 1) .. string.sub(v[2], j + 1, -1)
251 value[2] = tonumber(value[2]) 291 if 'boolean' == w.types[1] then module[v[2] ] = true end
252 if value[2] then 292 end
253 module[v[2] ] = value[2] 293 if '' == v[2] then v[2] = nil end -- Mark it as used.
254 value[2] = nil -- Mark it as used.
255 else
256 print('ERROR - Expected a number value for ' .. thingy.names[1])
257 end 294 end
258 else
259 module[v[2] ] = module[v[2] ] + 1
260 end 295 end
261 else
262 print('ERROR - Expected a number value for ' .. thingy.names[1])
263 end 296 end
264 end 297 end
265
266 if 'boolean' == thingy.types[1] then
267 if value then
268 -- Only parse the next value as a boolean if it doesn't have an introducer.
269 if ('' == value[1]) or ('=' == value[1]) then
270 module[v[2] ] = isBoolean(value[2])
271 value[2] = nil -- Mark it as used.
272 else
273 module[v[2] ] = true
274 end
275 else
276 print('ERROR - Expected a boolean value for ' .. thingy.names[1])
277 end
278 end
279
280 v[2] = nil -- Mark it as used.
281 end 298 end
282 end 299 end
283 end 300 end