mirror of
https://github.com/CCLeonOS/LeonOS.git
synced 2026-03-03 15:17:01 +00:00
feat(installer): 更新安装器版本至0.3.7 Beta 2
docs(help): 简化关于页面的内容并更新安装链接 feat(programs): 新增appdelete程序用于删除应用 - 安装器版本更新至0.3.7 Beta 2 - 关于页面内容简化并更新安装链接 - 新增appdelete程序,支持强制删除和交互式确认
This commit is contained in:
@@ -1,14 +1,6 @@
|
||||
LeonOS is ComputerCraft's LeonOS but with saner API design. It's also not licensed under the CCPL, but rather the MIT license -- so you can freely use LeonOS's code in other projects without being legally bound to license them under the CCPL.
|
||||
This help document is not complete.
|
||||
|
||||
LeonOS's website:
|
||||
|
||||
All APIs are implemented as described on the CC: Tweaked wiki at
|
||||
>>color blue
|
||||
https://tweaked.cc
|
||||
>>color white
|
||||
, with slight modifications to fit LeonOS's API design. Certain modules not written by Dan200 have been adapted from LeonOS, relicensed under the MIT license with permission from their authors.
|
||||
|
||||
See
|
||||
>>color blue
|
||||
https://ocaweso.me/LeonOS
|
||||
>>color white
|
||||
for more information on LeonOS.
|
||||
wget run https://gh.catmak.name/https://raw.githubusercontent.com/Leonmmcoset/LeonOS/refs/heads/main/installer.lua
|
||||
|
||||
120
data/computercraft/lua/rom/programs/appdelete.lua
Normal file
120
data/computercraft/lua/rom/programs/appdelete.lua
Normal file
@@ -0,0 +1,120 @@
|
||||
-- appdelete.lua - Delete applications from /app directory
|
||||
|
||||
local fs = require("fs")
|
||||
local tu = require("textutils")
|
||||
|
||||
local function show_help()
|
||||
print("Usage: appdelete <application_name> [options]")
|
||||
print("Deletes an application from the /app directory")
|
||||
print("")
|
||||
print("Options:")
|
||||
print(" --help, -h Show this help message")
|
||||
print(" --force, -f Force deletion without confirmation")
|
||||
end
|
||||
|
||||
local function delete_app(app_name, force)
|
||||
local app_dir = "/app"
|
||||
|
||||
-- 检查app目录是否存在
|
||||
if not fs.exists(app_dir) then
|
||||
print("Error: Applications directory not found at /app")
|
||||
return false
|
||||
end
|
||||
|
||||
-- 构建应用程序路径
|
||||
local app_path = fs.combine(app_dir, app_name)
|
||||
|
||||
-- 检查应用程序是否存在
|
||||
if not fs.exists(app_path) then
|
||||
-- 尝试添加.lua扩展名
|
||||
local lua_app_path = app_path .. ".lua"
|
||||
if fs.exists(lua_app_path) then
|
||||
app_path = lua_app_path
|
||||
else
|
||||
print("Error: Application '" .. app_name .. "' not found in /app directory")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- 确认删除
|
||||
if not force then
|
||||
print("Are you sure you want to delete '" .. app_name .. "'? (y/n)")
|
||||
local confirm = read()
|
||||
if confirm ~= "y" and confirm ~= "yes" then
|
||||
print("Deletion cancelled.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- 删除应用程序
|
||||
local is_dir = fs.isDir(app_path)
|
||||
local success, error_msg
|
||||
|
||||
if is_dir then
|
||||
success, error_msg = pcall(function()
|
||||
-- 删除目录及其内容
|
||||
for _, file in ipairs(fs.list(app_path)) do
|
||||
local file_path = fs.combine(app_path, file)
|
||||
if fs.isDir(file_path) then
|
||||
-- 递归删除子目录
|
||||
fs.delete(file_path)
|
||||
else
|
||||
-- 删除文件
|
||||
fs.delete(file_path)
|
||||
end
|
||||
end
|
||||
-- 删除空目录
|
||||
fs.delete(app_path)
|
||||
end)
|
||||
else
|
||||
-- 删除单个文件
|
||||
success, error_msg = pcall(fs.delete, app_path)
|
||||
end
|
||||
|
||||
if success then
|
||||
print("Application '" .. app_name .. "' deleted successfully.")
|
||||
return true
|
||||
else
|
||||
print("Error deleting application: " .. error_msg)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function main(args)
|
||||
if #args == 0 then
|
||||
show_help()
|
||||
return
|
||||
end
|
||||
|
||||
local app_name = nil
|
||||
local force = false
|
||||
|
||||
-- 解析命令行参数
|
||||
for _, arg in ipairs(args) do
|
||||
if arg == "--help" or arg == "-h" then
|
||||
show_help()
|
||||
return
|
||||
elseif arg == "--force" or arg == "-f" then
|
||||
force = true
|
||||
elseif not app_name then
|
||||
app_name = arg
|
||||
else
|
||||
-- 多余的参数
|
||||
print("Error: Too many arguments")
|
||||
show_help()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if not app_name then
|
||||
print("Error: Missing application name")
|
||||
show_help()
|
||||
return
|
||||
end
|
||||
|
||||
delete_app(app_name, force)
|
||||
end
|
||||
|
||||
-- 运行主函数
|
||||
local args = {...}
|
||||
main(args)
|
||||
@@ -1,5 +1,5 @@
|
||||
-- LeonOS installer
|
||||
local INSTALLER_VERSION = "0.3.7 Beta 1"
|
||||
local INSTALLER_VERSION = "0.3.7 Beta 2"
|
||||
local DEFAULT_ROM_DIR = "/leonos"
|
||||
|
||||
print("Start loading LeonOS installer ("..INSTALLER_VERSION..")...")
|
||||
|
||||
Reference in New Issue
Block a user