mirror of
https://github.com/CCLeonOS/LeonOS.git
synced 2026-03-03 15:17:01 +00:00
feat(包管理器): 实现LeonOS包管理系统基础功能
添加包管理器核心程序(pkg.lua)及相关支持文件 - 实现包安装、更新、移除、列表、搜索等功能 - 添加包元数据结构和本地存储管理 - 包含示例包和命令补全支持 - 更新系统版本至0.3.0
This commit is contained in:
31
data/computercraft/lua/rom/completions/pkg.lua
Normal file
31
data/computercraft/lua/rom/completions/pkg.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
-- pkg command completion
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
-- 定义pkg命令的补全函数
|
||||
local function pkg_completion(shell, index, text, previous)
|
||||
-- 子命令补全
|
||||
if index == 1 then
|
||||
return completion.choice(text, {"install", "update", "remove", "list", "search", "info", "help"})
|
||||
end
|
||||
|
||||
-- 选项补全 (--force, --local)
|
||||
if text:sub(1, 2) == "--" then
|
||||
return completion.choice(text, {"--force", "--local"})
|
||||
end
|
||||
|
||||
-- 命令特定补全
|
||||
local command = previous[1]
|
||||
if command == "install" or command == "update" or command == "remove" or command == "info" then
|
||||
-- 这里可以添加包名补全逻辑
|
||||
-- 目前返回空列表
|
||||
return {}
|
||||
elseif command == "search" then
|
||||
-- 搜索查询不需要特定补全
|
||||
return {}
|
||||
end
|
||||
|
||||
return {}
|
||||
end
|
||||
|
||||
shell.setCompletionFunction("pkg", pkg_completion)
|
||||
7
data/computercraft/lua/rom/completions/tree.lua
Normal file
7
data/computercraft/lua/rom/completions/tree.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- tree command completion
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("tree", completion.build(
|
||||
{completion.dir, many = true}
|
||||
))
|
||||
Reference in New Issue
Block a user