summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-06-07 22:46:53 +0800
committerGitHub <[email protected]>2025-06-07 22:46:53 +0800
commit976fcf8c2a672ca8abf8eae54497c2b1f7d75142 (patch)
treec6f943aec2950c9daad7f94a07f63f925b14487a
parent6989184ed0b7e61614d3f41bdbcdac4c6075ac77 (diff)
parent4ab3e401f14639f14f590fb091187b674cc90fb5 (diff)
Merge pull request #6524 from lonless9/feat-group
adds target group filtering to `show targets`
-rw-r--r--xmake/plugins/show/lists/targets.lua16
-rw-r--r--xmake/plugins/show/xmake.lua1
2 files changed, 14 insertions, 3 deletions
diff --git a/xmake/plugins/show/lists/targets.lua b/xmake/plugins/show/lists/targets.lua
index 50507aa1b..fa85de628 100644
--- a/xmake/plugins/show/lists/targets.lua
+++ b/xmake/plugins/show/lists/targets.lua
@@ -19,17 +19,27 @@
--
-- imports
+import("core.base.option")
import("core.project.config")
import("core.project.project")
import("core.platform.platform")
import(".showlist")
--- show all platforms
+-- show all targets (optionally filtered by group)
function main()
config.load()
+
local targets = {}
- for name, _ in pairs(project.targets()) do
- table.insert(targets, name)
+ local group_pattern = option.get("group")
+ if group_pattern then
+ group_pattern = "^" .. path.pattern(group_pattern) .. "$"
end
+ for name, target in pairs(project.targets()) do
+ local group = target:get("group")
+ if (target:is_default() and not group_pattern) or (group_pattern and group and group:match(group_pattern)) then
+ table.insert(targets, name)
+ end
+ end
+
showlist(targets)
end
diff --git a/xmake/plugins/show/xmake.lua b/xmake/plugins/show/xmake.lua
index bae15471c..33fb51635 100644
--- a/xmake/plugins/show/xmake.lua
+++ b/xmake/plugins/show/xmake.lua
@@ -29,6 +29,7 @@ task("show")
values = function (complete, opt)
return import("list").lists()
end},
+ {'g', "group", "kv", nil, "Filter targets by the given group name."},
{nil, "json", "k", false, "Show information with json format."},
{'t', "target", "kv", nil, "Show the information of the given target.",
values = function (complete, opt)