Fixed some other thing

This commit is contained in:
2024-02-23 16:48:03 +01:00
parent f82608dad6
commit 31b9ca7e8c

View File

@@ -10,33 +10,7 @@ local keyboard=require("keyboard")
local repository = "seesberger/PowerManager" local repository = "seesberger/PowerManager"
local targetFilepath = "/usr/PowerManager/" local targetFilepath = "/usr/PowerManager/"
local helpText = "Usage:\n" .. local helpText = "Usage:\n" .. "updater <nothing> - manual update and install\n".."updater -h - this particular text\n" .. " '' -a - automatic update no install\n" .. " '' -i - automatic update and install"
"updater <nothing> - manual update and install\n"..
"updater -h - this particular text\n" ..
" '' -a - automatic update no install\n" ..
" '' -i - automatic update and install"
if #args<1 then
print("No Arguments given. Manual process...")
manualUpdate()
return
end
if args == "-h" then
print(helpText)
return
elseif args == "-a" then
automaticUpdate()
return
elseif args == "-i" then
automaticUpdate()
automaticInstall()
return
else
print('"'..args[1]..'" - Bad argument.')
print(helpText)
return
end
function manualUpdate() function manualUpdate()
downloadRepo(repository, targetFilepath, false) downloadRepo(repository, targetFilepath, false)
@@ -57,8 +31,8 @@ end
function downloadRepo(repo, target, auto) function downloadRepo(repo, target, auto)
if not repo:match("^[%w-.]*/[%w-.]*$") then if not repo:match("^[%w-.]*/[%w-.]*$") then
print('"'..repo..'" does not look like a valid repo identifier.\nShould be <owner>/<reponame>') print('"'..repo..'" does not look like a valid repo identifier.\nShould be <owner>/<reponame>')
return return
end end
target=target and ("/"..target:match("^/?(.-)/?$").."/") or "/tmp/"..repo target=target and ("/"..target:match("^/?(.-)/?$").."/") or "/tmp/"..repo
@@ -168,7 +142,7 @@ function downloadRepo(repo, target, auto)
end end
local replaceMode="ask" local replaceMode="ask"
if auto then replacemode == "always" end if auto then replacemode = "always" end
for i=1,#files do for i=1,#files do
local replace=nil local replace=nil
if filesystem.exists(target..files[i]) then if filesystem.exists(target..files[i]) then
@@ -233,3 +207,25 @@ function downloadRepo(repo, target, auto)
end end
end end
if #args<1 then
print("No Arguments given. Manual process...")
manualUpdate()
return
end
if args == "-h" then
print(helpText)
return
elseif args == "-a" then
automaticUpdate()
return
elseif args == "-i" then
automaticUpdate()
automaticInstall()
return
else
print('"'..args[1]..'" - Bad argument.')
print(helpText)
return
end