added arguments to shortcut and removed installer.lua as it was unnecessary

This commit is contained in:
2024-02-23 17:16:35 +01:00
parent bc539f13b6
commit f8508b9d80
4 changed files with 24 additions and 37 deletions

View File

@@ -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") os.execute("mv shortcut.lua /usr/bin/powerman.lua")

View File

@@ -1,2 +1 @@
dofile("/usr/PowerManager/updater.lua")
dofile("/usr/PowerManager/PowerManager.lua") dofile("/usr/PowerManager/PowerManager.lua")

View File

@@ -1 +1,20 @@
dofile("/home/PowerManager/main.lua") 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

View File

@@ -17,7 +17,7 @@ function manualUpdate()
end end
function manualInstall() function manualInstall()
os.execute(targetFilepath.."installer.lua -m") os.execute("mv shortcut.lua /usr/bin/powerman.lua")
end end
function automaticUpdate() function automaticUpdate()
@@ -25,10 +25,10 @@ function automaticUpdate()
end end
function automaticInstall() function automaticInstall()
os.execute(targetFilepath.."installer.lua -a") os.execute("mv shortcut.lua /usr/bin/powerman.lua")
end end
function downloadRepo(repo, target, auto) function downloadRepo(repo, target, automatic)
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>')
@@ -142,7 +142,7 @@ function downloadRepo(repo, target, auto)
end end
local replaceMode="ask" local replaceMode="ask"
if auto then replacemode = "always" end if auto == true 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