Advertisement
DOGGYWOOF

Doggy OS Lite Package-editor

May 27th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. -- List all files in the /disk/packages directory
  2. local function listFiles()
  3. local files = fs.list("/disk/packages")
  4. local filteredFiles = {}
  5.  
  6. for _, file in ipairs(files) do
  7. if file ~= "package-installer" and file ~= "package-remover" and file ~= "package-editor" then
  8. table.insert(filteredFiles, file)
  9. end
  10. end
  11.  
  12. return filteredFiles
  13. end
  14.  
  15. -- Display files and allow the user to select one
  16. local function selectFile(files)
  17. print("Select a file to edit:")
  18. for i, file in ipairs(files) do
  19. print(i .. ". " .. file)
  20. end
  21.  
  22. local choice
  23. repeat
  24. write("Enter number: ")
  25. choice = tonumber(read())
  26. until choice and choice >= 1 and choice <= #files
  27.  
  28. return files[choice]
  29. end
  30.  
  31. -- Main program
  32. local function main()
  33. local files = listFiles()
  34. if #files == 0 then
  35. print("No files available to edit.")
  36. return
  37. end
  38.  
  39. local selectedFile = selectFile(files)
  40. shell.run("edit /disk/packages/" .. selectedFile)
  41. end
  42.  
  43. -- Run the main program
  44. main()
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement