diff --git a/data/computercraft/lua/rom/programs/applist.lua b/data/computercraft/lua/rom/programs/applist.lua new file mode 100644 index 0000000..3f0afa7 --- /dev/null +++ b/data/computercraft/lua/rom/programs/applist.lua @@ -0,0 +1,76 @@ +-- applist.lua - List applications in /app directory + +local fs = require("fs") +local tu = require("textutils") + +local function show_help() + print("Usage: applist [options]") + print("Lists all applications in the /app directory") + print("") + print("Options:") + print(" --help, -h Show this help message") + print(" --verbose, -v Show more details about each application") +end + +local function list_apps(verbose) + local app_dir = "/app" + + -- 检查app目录是否存在 + if not fs.exists(app_dir) then + print("No applications directory found at /app") + return + end + + -- 获取app目录中的文件列表 + local files = fs.list(app_dir) + + if #files == 0 then + print("No applications installed in /app directory") + return + end + + print("Installed applications:") + print("======================") + + for _, file in ipairs(files) do + local file_path = fs.combine(app_dir, file) + local is_dir = fs.isDir(file_path) + + if is_dir then + -- 如果是目录,可能是一个应用程序文件夹 + print("[" .. file .. "]") + if verbose then + -- 在详细模式下,显示目录中的.lua文件 + local sub_files = fs.list(file_path) + for _, sub_file in ipairs(sub_files) do + if sub_file:sub(-4) == ".lua" then + print(" - " .. sub_file) + end + end + end + elseif file:sub(-4) == ".lua" then + -- 如果是.lua文件,直接显示 + print(file:sub(1, -5)) -- 移除.lua扩展名 + end + end +end + +local function main(args) + local verbose = false + + -- 解析命令行参数 + for _, arg in ipairs(args) do + if arg == "--help" or arg == "-h" then + show_help() + return + elseif arg == "--verbose" or arg == "-v" then + verbose = true + end + end + + list_apps(verbose) +end + +-- 运行主函数 +local args = {...} +main(args) \ No newline at end of file diff --git a/data/computercraft/lua/rom/programs/shell.lua b/data/computercraft/lua/rom/programs/shell.lua index 9f2cfd6..91fc58b 100644 --- a/data/computercraft/lua/rom/programs/shell.lua +++ b/data/computercraft/lua/rom/programs/shell.lua @@ -69,7 +69,8 @@ local aliases = { sh = "shell", ps = "threads", restart = "reboot", - version = "ver" + version = "ver", + package = "pkg" } for k, v in pairs(aliases) do diff --git a/installer.lua b/installer.lua index 59cc332..6d651d8 100644 --- a/installer.lua +++ b/installer.lua @@ -1,5 +1,5 @@ -- LeonOS installer -local INSTALLER_VERSION = "0.3.6 Beta 3" +local INSTALLER_VERSION = "0.3.6 Beta 4" local DEFAULT_ROM_DIR = "/leonos" print("Start loading LeonOS installer ("..INSTALLER_VERSION..")...")