diff options
| -rw-r--r-- | xmake/plugins/show/lists/targets.lua | 16 | ||||
| -rw-r--r-- | xmake/plugins/show/xmake.lua | 1 |
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) |
