From f8508b9d8005b0f1898b2d48b9032c87bbc15e66 Mon Sep 17 00:00:00 2001 From: Frederick Meisel Date: Fri, 23 Feb 2024 17:16:35 +0100 Subject: [PATCH] added arguments to shortcut and removed installer.lua as it was unnecessary --- installer.lua | 31 ------------------------------- main.lua | 1 - shortcut.lua | 21 ++++++++++++++++++++- updater.lua | 8 ++++---- 4 files changed, 24 insertions(+), 37 deletions(-) diff --git a/installer.lua b/installer.lua index 2aa6d26..8beef98 100644 --- a/installer.lua +++ b/installer.lua @@ -1,33 +1,2 @@ -local args = {...} -local headerText = "PowerManager - Installer\n" -local startOnBootText = "Beim Boot ausführen?" -local automaticUpdateText = "Automatisch updates herunterladen?" - ---returns the user input as bool (Y/N) -> (1/0) -local function askThatDamnUser(prompt) - while true do - print(">>> " .. prompt) - local userInput = io.read() - - if userInput == "Y" then - return true - elseif userInput == "N" then - return false - else - print("Hallo? => ( Y / N ) Nicht -> " .. userInput) - end - end -end - - -local startOnBoot = askThatDamnUser(startOnBootText) -local automaticUpdate = askThatDamnUser(automaticUpdateText) - -if startOnBoot then - print("notImplementedYet") -end -if automaticUpdate then - print("notImplementedYet") -end os.execute("mv shortcut.lua /usr/bin/powerman.lua") \ No newline at end of file diff --git a/main.lua b/main.lua index 6c48c69..856a11b 100644 --- a/main.lua +++ b/main.lua @@ -1,2 +1 @@ -dofile("/usr/PowerManager/updater.lua") dofile("/usr/PowerManager/PowerManager.lua") \ No newline at end of file diff --git a/shortcut.lua b/shortcut.lua index 761aeaa..a4eeb19 100644 --- a/shortcut.lua +++ b/shortcut.lua @@ -1 +1,20 @@ -dofile("/home/PowerManager/main.lua") \ No newline at end of file +local args = {...} +local helpText = "This is a tool for displaying and managing your Power cells and generators." + + +if #args<1 then + dofile("/usr/PowerManager/main.lua") + return +end + +if args[1] == "-h" then + print(helpText) + return +elseif args[1] == "update" then + dofile("/usr/PowerManager/updater.lua") + return +else + print('"'..args[1]..'" - Bad argument. you can use: powerman update') + print(helpText) + return +end \ No newline at end of file diff --git a/updater.lua b/updater.lua index b1ee1ea..21b6dc5 100644 --- a/updater.lua +++ b/updater.lua @@ -17,7 +17,7 @@ function manualUpdate() end function manualInstall() - os.execute(targetFilepath.."installer.lua -m") + os.execute("mv shortcut.lua /usr/bin/powerman.lua") end function automaticUpdate() @@ -25,10 +25,10 @@ function automaticUpdate() end function automaticInstall() - os.execute(targetFilepath.."installer.lua -a") + os.execute("mv shortcut.lua /usr/bin/powerman.lua") end -function downloadRepo(repo, target, auto) +function downloadRepo(repo, target, automatic) if not repo:match("^[%w-.]*/[%w-.]*$") then print('"'..repo..'" does not look like a valid repo identifier.\nShould be /') @@ -142,7 +142,7 @@ function downloadRepo(repo, target, auto) end local replaceMode="ask" - if auto then replacemode = "always" end + if auto == true then replaceMode = "always" end for i=1,#files do local replace=nil if filesystem.exists(target..files[i]) then