summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGly <[email protected]>2022-12-26 16:12:21 +0100
committerGly <[email protected]>2022-12-26 16:12:21 +0100
commit841c51ede7ef6188759d13843d1e4b680664d0d9 (patch)
tree85cd74cf0cabc92f8f7ff854fa9538313b7c713d
parent2926e7d47658667fad27f43adf1f63838754e886 (diff)
Add package completion on xrepo install
-rw-r--r--xmake/modules/private/xrepo/action/install.lua3
-rw-r--r--xmake/modules/private/xrepo/quick_search/complete.lua11
2 files changed, 13 insertions, 1 deletions
diff --git a/xmake/modules/private/xrepo/action/install.lua b/xmake/modules/private/xrepo/action/install.lua
index f650e5ff1..abef10ada 100644
--- a/xmake/modules/private/xrepo/action/install.lua
+++ b/xmake/modules/private/xrepo/action/install.lua
@@ -79,7 +79,8 @@ function menu_options()
" - xrepo install -p iphoneos -a arm64 \"zlib >=1.2.0\"",
" - xrepo install -p android [--ndk=/xxx] -m debug \"pcre2 10.x\"",
" - xrepo install -p mingw [--mingw=/xxx] -k shared zlib",
- " - xrepo install conan::zlib/1.2.11 vcpkg::zlib"}
+ " - xrepo install conan::zlib/1.2.11 vcpkg::zlib",
+ values = function (complete, opt) return import("private.xrepo.quick_search.complete")(complete, opt) end}
}
-- show menu options
diff --git a/xmake/modules/private/xrepo/quick_search/complete.lua b/xmake/modules/private/xrepo/quick_search/complete.lua
new file mode 100644
index 000000000..48de72e56
--- /dev/null
+++ b/xmake/modules/private/xrepo/quick_search/complete.lua
@@ -0,0 +1,11 @@
+import("private.xrepo.quick_search.cache")
+function main(complete, opt)
+ local packages = cache.get()
+ local candidates = {}
+ for _, package in ipairs(packages) do
+ if package.name:startswith(complete) then
+ table.insert(candidates, package.name)
+ end
+ end
+ return candidates
+end \ No newline at end of file