summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-04-18 21:21:33 +0800
committerruki <[email protected]>2026-04-20 09:35:36 +0800
commit51be800bddfa199774206393cb8d7e0749f59756 (patch)
tree6cc51dcda14a0469125e8596fc6525aa6584782c
parent8a58cf9cb94e016c8a2297f1edab6b883d02e847 (diff)
improve xmake show --info
-rw-r--r--xmake/plugins/show/info/depgraph.lua7
-rw-r--r--xmake/plugins/show/info/target.lua1
-rw-r--r--xmake/plugins/show/list.lua12
-rw-r--r--xmake/plugins/show/xmake.lua5
4 files changed, 22 insertions, 3 deletions
diff --git a/xmake/plugins/show/info/depgraph.lua b/xmake/plugins/show/info/depgraph.lua
index 55a2d7360..60e667002 100644
--- a/xmake/plugins/show/info/depgraph.lua
+++ b/xmake/plugins/show/info/depgraph.lua
@@ -27,6 +27,7 @@ import("private.detect.check_targetname")
function _collect_target_entry(target)
local deps = table.wrap(target:get("deps"))
+ json.mark_as_array(deps)
return {
name = target:name(),
@@ -75,6 +76,7 @@ function _collect_target_graph(root_target)
end
end
+ json.mark_as_array(roots)
return {
root_targets = roots,
targets = targets
@@ -87,14 +89,15 @@ function _print_target_graph(graph)
cprint(" ${color.dump.string}root targets${clear}: %s", table.concat(graph.root_targets, ", "))
cprint("")
for _, target in ipairs(graph.targets) do
- local deps = #target.deps > 0 and table.concat(target.deps, ", ") or "(none)"
cprint(" ${color.dump.string}%s${clear}:", target.name)
cprint(" ${dim}kind${clear}: %s", target.kind)
if target.group then
cprint(" ${dim}group${clear}: %s", target.group)
end
cprint(" ${dim}default${clear}: %s", tostring(target.default))
- cprint(" ${dim}deps${clear}: %s", deps)
+ if #target.deps > 0 then
+ cprint(" ${dim}deps${clear}: %s", table.concat(target.deps, ", "))
+ end
end
end
diff --git a/xmake/plugins/show/info/target.lua b/xmake/plugins/show/info/target.lua
index e63a51ea7..bfa88ad92 100644
--- a/xmake/plugins/show/info/target.lua
+++ b/xmake/plugins/show/info/target.lua
@@ -367,6 +367,7 @@ function main(name)
json = option.get("json"),
pretty = option.get("pretty")
}
+ assert(name, "please specify the target name, e.g. xmake show --info=target --target=xxx")
local target = assert(check_targetname(name))
local info = _collect_target_info(target)
diff --git a/xmake/plugins/show/list.lua b/xmake/plugins/show/list.lua
index fb2914964..301048ce2 100644
--- a/xmake/plugins/show/list.lua
+++ b/xmake/plugins/show/list.lua
@@ -29,3 +29,15 @@ function lists()
end
return values
end
+
+-- get all info values
+function infos()
+ local values = {}
+ for _, filepath in ipairs(os.files(path.join(os.scriptdir(), "info", "*.lua"))) do
+ local name = path.basename(filepath)
+ if name ~= "basic" and name ~= "target" then
+ table.insert(values, name)
+ end
+ end
+ return values
+end
diff --git a/xmake/plugins/show/xmake.lua b/xmake/plugins/show/xmake.lua
index cb16ff207..77d2be2b3 100644
--- a/xmake/plugins/show/xmake.lua
+++ b/xmake/plugins/show/xmake.lua
@@ -32,7 +32,10 @@ task("show")
{'g', "group", "kv", nil, "Filter targets by the given group name."},
{nil, "json", "k", false, "Show information with json format."},
{nil, "pretty", "k", false, "Enable pretty formatted json output."},
- {'i', "info", "kv", nil, "Show the given information."},
+ {'i', "info", "kv", nil, "Show the given information.",
+ values = function (complete, opt)
+ return import("list").infos()
+ end},
{'t', "target", "kv", nil, "Show the information of the given target.",
values = function (complete, opt)
return import("private.utils.complete_helper.targets")(complete, opt)