diff options
| author | ruki <[email protected]> | 2026-04-20 22:37:26 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-04-20 22:37:26 +0800 |
| commit | d782aae00f82bd160b0fc5c0cdac1ba27ae8ade1 (patch) | |
| tree | 17cfef203818daeb5ca86af19677440d4080cb3c /xmake/plugins/show/info/depgraph.lua | |
| parent | 35d37f98381d8486f23b7761c90acdba3fc2e9d1 (diff) | |
add --format
Diffstat (limited to 'xmake/plugins/show/info/depgraph.lua')
| -rw-r--r-- | xmake/plugins/show/info/depgraph.lua | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/xmake/plugins/show/info/depgraph.lua b/xmake/plugins/show/info/depgraph.lua index e399a46df..2c73f3abc 100644 --- a/xmake/plugins/show/info/depgraph.lua +++ b/xmake/plugins/show/info/depgraph.lua @@ -139,14 +139,19 @@ function main(name) end local graph = _collect_target_graph(root_target) - assert(not (option.get("json") and option.get("dot")), "--json and --dot are mutually exclusive") - if option.get("json") then - local json_opt - if option.get("pretty") then - json_opt = {pretty = true, orderkeys = true} + + -- support --format=json/dot/plain, with --json/--pretty backward compatibility + local format = option.get("format") or "plain" + if format == "plain" and option.get("json") then + format = "json" + end + if format == "json" then + local json_opt = {pretty = true, orderkeys = true} + if option.get("json") and not option.get("pretty") then + json_opt = nil end print(json.encode(graph, json_opt)) - elseif option.get("dot") then + elseif format == "dot" then _print_dot_graph(graph) else _print_target_graph(graph) |
