mirror of
https://github.com/CCLeonOS/LeonOS.git
synced 2026-03-03 15:17:01 +00:00
feat(配置程序): 添加查找设置功能并修复通配符匹配
为config程序添加find命令,支持按名称或描述搜索设置,并支持大小写不敏感选项 修复find.lua中的通配符匹配问题 优化history.lua中的线程环境访问逻辑 添加测试配置文件test_config_find.lua 更新安装程序版本号
This commit is contained in:
70
data/computercraft/lua/rom/programs/test_config_find.lua
Normal file
70
data/computercraft/lua/rom/programs/test_config_find.lua
Normal file
@@ -0,0 +1,70 @@
|
||||
local shell = require("shell")
|
||||
local term = require("term")
|
||||
local colors = require("colors")
|
||||
|
||||
-- 保存当前颜色设置
|
||||
local old_fg = term.getTextColor()
|
||||
local old_bg = term.getBackgroundColor()
|
||||
|
||||
-- 测试函数
|
||||
local function run_test(name, command)
|
||||
term.setTextColor(colors.cyan)
|
||||
print("\n=== Running test: " .. name .. " ===")
|
||||
term.setTextColor(colors.white)
|
||||
print("Command: " .. command)
|
||||
print("----------------------------------------")
|
||||
shell.run(command)
|
||||
print("----------------------------------------")
|
||||
end
|
||||
|
||||
-- 主测试函数
|
||||
local function main()
|
||||
-- 恢复颜色设置
|
||||
term.setTextColor(old_fg)
|
||||
term.setBackgroundColor(old_bg)
|
||||
term.at(1, 1).clearLine()
|
||||
|
||||
-- 设置标题颜色
|
||||
term.setTextColor(colors.white)
|
||||
term.setBackgroundColor(colors.cyan)
|
||||
term.at(1, 1).write("=== Testing Config Find Command ===")
|
||||
term.setTextColor(old_fg)
|
||||
term.setBackgroundColor(old_bg)
|
||||
term.at(1, 2)
|
||||
|
||||
-- 测试1: 基本find命令 - 搜索带"hidden"的设置
|
||||
run_test("Basic search for 'hidden'", "config find hidden")
|
||||
|
||||
-- 测试2: 带--details选项的find命令
|
||||
run_test("Search with details", "config find hidden --details")
|
||||
|
||||
-- 测试3: 大小写不敏感搜索
|
||||
run_test("Case-insensitive search", "config find HIDDEN -i")
|
||||
|
||||
-- 测试4: 使用长选项--case-insensitive
|
||||
run_test("Case-insensitive search (long option)", "config find HIDDEN --case-insensitive")
|
||||
|
||||
-- 测试5: 搜索描述中的关键词
|
||||
-- 注意:这取决于实际设置的描述内容,可能需要根据系统调整
|
||||
run_test("Search in descriptions", "config find directory")
|
||||
|
||||
-- 测试6: 组合选项 - 带详细信息的大小写不敏感搜索
|
||||
run_test("Combined options", "config find HIDDEN -i --details")
|
||||
|
||||
-- 测试7: 搜索不存在的模式
|
||||
run_test("Search for non-existent pattern", "config find nonexistentpattern123")
|
||||
|
||||
-- 测试8: 查看帮助信息,确认find命令已正确添加
|
||||
run_test("Check help message", "config --help")
|
||||
|
||||
-- 测试9: 测试find命令的错误用法
|
||||
run_test("Test invalid usage", "config find")
|
||||
|
||||
-- 显示测试完成信息
|
||||
term.setTextColor(colors.green)
|
||||
print("\n=== All tests completed ===")
|
||||
term.setTextColor(old_fg)
|
||||
end
|
||||
|
||||
-- 运行测试
|
||||
main()
|
||||
Reference in New Issue
Block a user