mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
Fixed IRC/VK, added missing system.parseArguments functionality
This commit is contained in:
parent
8e73b7f96d
commit
c8352db0e3
@ -7,6 +7,7 @@ local system = require("System")
|
||||
local paths = require("Paths")
|
||||
local system = require("System")
|
||||
local text = require("Text")
|
||||
local event = require("Event")
|
||||
local number = require("Number")
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
@ -5,7 +5,7 @@ local filesystem = require("Filesystem")
|
||||
local color = require("Color")
|
||||
local image = require("Image")
|
||||
local internet = require("Internet")
|
||||
local json = require("json")
|
||||
local json = require("JSON")
|
||||
local color = require("Color")
|
||||
local paths = require("Paths")
|
||||
local system = require("System")
|
||||
|
||||
@ -110,13 +110,32 @@ function system.createShortcut(where, forWhat)
|
||||
end
|
||||
|
||||
function system.parseArguments(...)
|
||||
local arguments, options = {...}, {}
|
||||
local i = 1
|
||||
local i, arguments, options, dashes, data, key, value = 1, {...}, {}
|
||||
|
||||
while i <= #arguments do
|
||||
local option = arguments[i]:match("^%-+(.+)")
|
||||
if option then
|
||||
options[option] = true
|
||||
if type(arguments[i]) == "string" then
|
||||
dashes, data = arguments[i]:match("^(%-+)(.+)")
|
||||
|
||||
if dashes then
|
||||
-- Single dash option
|
||||
if #dashes == 1 then
|
||||
for i = 1, unicode.len(data) do
|
||||
options[unicode.sub(data, i, i)] = true
|
||||
end
|
||||
-- Multiple dash option
|
||||
else
|
||||
-- Option with key and value
|
||||
key, value = data:match("^([^=]+)=(.+)")
|
||||
if key then
|
||||
options[key] = value
|
||||
else
|
||||
options[data] = true
|
||||
end
|
||||
end
|
||||
|
||||
table.remove(arguments, i)
|
||||
i = i - 1
|
||||
end
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user