From 31b9ca7e8c84522cd53127af5fb9f5eb0ad92557 Mon Sep 17 00:00:00 2001 From: Frederick Meisel Date: Fri, 23 Feb 2024 16:48:03 +0100 Subject: [PATCH] Fixed some other thing --- updater.lua | 56 +++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/updater.lua b/updater.lua index 2a2653a..f7bcfd7 100644 --- a/updater.lua +++ b/updater.lua @@ -10,33 +10,7 @@ local keyboard=require("keyboard") local repository = "seesberger/PowerManager" local targetFilepath = "/usr/PowerManager/" -local helpText = "Usage:\n" .. - "updater - 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 +local helpText = "Usage:\n" .. "updater - manual update and install\n".."updater -h - this particular text\n" .. " '' -a - automatic update no install\n" .. " '' -i - automatic update and install" function manualUpdate() downloadRepo(repository, targetFilepath, false) @@ -57,8 +31,8 @@ end function downloadRepo(repo, target, auto) if not repo:match("^[%w-.]*/[%w-.]*$") then - print('"'..repo..'" does not look like a valid repo identifier.\nShould be /') - return + print('"'..repo..'" does not look like a valid repo identifier.\nShould be /') + return end target=target and ("/"..target:match("^/?(.-)/?$").."/") or "/tmp/"..repo @@ -168,7 +142,7 @@ function downloadRepo(repo, target, auto) end local replaceMode="ask" - if auto then replacemode == "always" end + if auto then replacemode = "always" end for i=1,#files do local replace=nil if filesystem.exists(target..files[i]) then @@ -233,3 +207,25 @@ function downloadRepo(repo, target, auto) 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 +