mirror of
https://github.com/CCLeonOS/LeonOS.git
synced 2026-03-03 06:47:00 +00:00
feat(completions): 添加多个命令的自动补全功能
添加了多个命令的自动补全脚本,包括imageview、time、about等常用命令 同时修复了pkg命令中文件名输出格式的问题
This commit is contained in:
6
data/computercraft/lua/rom/completions/about.lua
Normal file
6
data/computercraft/lua/rom/completions/about.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("about", completion.build(
|
||||
-- about command doesn't take parameters
|
||||
))
|
||||
7
data/computercraft/lua/rom/completions/app.lua
Normal file
7
data/computercraft/lua/rom/completions/app.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("app", completion.build(
|
||||
{completion.choice, choices = {"install", "update", "remove", "list"}, desc = "Command"},
|
||||
{completion.anything, desc = "App name", optional = true}
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/appdelete.lua
Normal file
6
data/computercraft/lua/rom/completions/appdelete.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("appdelete", completion.build(
|
||||
{completion.anything, desc = "App name"}
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/applist.lua
Normal file
6
data/computercraft/lua/rom/completions/applist.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("applist", completion.build(
|
||||
-- applist command doesn't take parameters
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/clear.lua
Normal file
6
data/computercraft/lua/rom/completions/clear.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("clear", completion.build(
|
||||
-- clear command doesn't take parameters
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/commands.lua
Normal file
6
data/computercraft/lua/rom/completions/commands.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("commands", completion.build(
|
||||
-- commands command doesn't take parameters
|
||||
))
|
||||
7
data/computercraft/lua/rom/completions/config.lua
Normal file
7
data/computercraft/lua/rom/completions/config.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("config", completion.build(
|
||||
{completion.anything, desc = "Config key"},
|
||||
{completion.anything, desc = "Config value", optional = true}
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/craftos.lua
Normal file
6
data/computercraft/lua/rom/completions/craftos.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("craftos", completion.build(
|
||||
-- craftos command doesn't take parameters
|
||||
))
|
||||
7
data/computercraft/lua/rom/completions/find.lua
Normal file
7
data/computercraft/lua/rom/completions/find.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("find", completion.build(
|
||||
{completion.anything, desc = "Search pattern"},
|
||||
{completion.dir, desc = "Directory", optional = true}
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/helplist.lua
Normal file
6
data/computercraft/lua/rom/completions/helplist.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("helplist", completion.build(
|
||||
-- helplist command doesn't take parameters
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/history.lua
Normal file
6
data/computercraft/lua/rom/completions/history.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("history", completion.build(
|
||||
{completion.number, desc = "Number of entries", optional = true}
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/imageview.lua
Normal file
6
data/computercraft/lua/rom/completions/imageview.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("imageview", completion.build(
|
||||
completion.anything
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/lua.lua
Normal file
6
data/computercraft/lua/rom/completions/lua.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("lua", completion.build(
|
||||
{completion.dirOrFile, desc = "Script file", optional = true}
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/peripherals.lua
Normal file
6
data/computercraft/lua/rom/completions/peripherals.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("peripherals", completion.build(
|
||||
-- peripherals command doesn't take parameters
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/programs.lua
Normal file
6
data/computercraft/lua/rom/completions/programs.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("programs", completion.build(
|
||||
-- programs command doesn't take parameters
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/shell.lua
Normal file
6
data/computercraft/lua/rom/completions/shell.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("shell", completion.build(
|
||||
{completion.anything, desc = "Command", optional = true}
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/storage.lua
Normal file
6
data/computercraft/lua/rom/completions/storage.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("storage", completion.build(
|
||||
-- storage command doesn't take parameters
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/threads.lua
Normal file
6
data/computercraft/lua/rom/completions/threads.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("threads", completion.build(
|
||||
-- threads command doesn't take parameters
|
||||
))
|
||||
6
data/computercraft/lua/rom/completions/time.lua
Normal file
6
data/computercraft/lua/rom/completions/time.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("time", completion.build(
|
||||
-- time command doesn't take parameters
|
||||
))
|
||||
7
data/computercraft/lua/rom/completions/wget.lua
Normal file
7
data/computercraft/lua/rom/completions/wget.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
local shell = require("shell")
|
||||
local completion = require("cc.shell.completion")
|
||||
|
||||
shell.setCompletionFunction("wget", completion.build(
|
||||
{completion.anything, desc = "URL"},
|
||||
{completion.dirOrFile, desc = "Output file", optional = true}
|
||||
))
|
||||
@@ -100,9 +100,9 @@ print(" pkg list - List installed packages")
|
||||
]]
|
||||
main_file:write(main_file_content)
|
||||
main_file:close()
|
||||
print("Created ]] .. pkg_name .. [[.lua")
|
||||
print("Created " .. pkg_name .. ".lua")
|
||||
else
|
||||
print("Error: Failed to create ]] .. pkg_name .. [[.lua")
|
||||
print("Error: Failed to create " .. pkg_name .. ".lua")
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user