diff options
| author | ruki <[email protected]> | 2026-06-17 23:49:50 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-06-17 23:49:50 +0800 |
| commit | eba488dafedd88c1f19e23132276872aac877b73 (patch) | |
| tree | a577ac74585545b465b12caa03480d7665f2f5d6 /xmake/plugins/format | |
| parent | ba2df770b8430a8f8e593d34dc05de051a59a1bd (diff) | |
add targets arugment support
Diffstat (limited to 'xmake/plugins/format')
| -rw-r--r-- | xmake/plugins/format/main.lua | 12 | ||||
| -rw-r--r-- | xmake/plugins/format/xmake.lua | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua index 7d5e1de66..f8be7c428 100644 --- a/xmake/plugins/format/main.lua +++ b/xmake/plugins/format/main.lua @@ -94,10 +94,12 @@ function _get_file_patterns(sourcefiles) end -- get all the targets that match the group or targetname -function _get_targets(targetname, group_pattern) +function _get_targets(targetnames, group_pattern) local targets = {} - if targetname then - table.insert(targets, project.target(targetname)) + if targetnames and #targetnames > 0 then + for _, targetname in ipairs(targetnames) do + table.insert(targets, project.target(targetname)) + end else for _, target in pairs(project.targets()) do local group = target:get("group") @@ -178,8 +180,8 @@ function main() -- collect sourcefiles local sourcefiles = {} - local targetname, group_pattern = action_utils.get_target_and_group() - local targets = _get_targets(targetname, group_pattern) + local targetnames, group_pattern = action_utils.get_targets_and_group() + local targets = _get_targets(targetnames, group_pattern) if option.get("files") then local filepatterns = _get_file_patterns(option.get("files")) for _, target in ipairs(targets) do diff --git a/xmake/plugins/format/xmake.lua b/xmake/plugins/format/xmake.lua index d9e34572b..5de1b8120 100644 --- a/xmake/plugins/format/xmake.lua +++ b/xmake/plugins/format/xmake.lua @@ -45,7 +45,9 @@ task("format") " - xmake format --files='src/**.c|excluded_file.c'", " - xmake format --files='src/main.c" .. path.envsep() .. "src/test.c'" }, {}, - {nil, "target", "v", nil, "The target name. It will format all default targets if this parameter is not specified." + {nil, "targets", "vs", nil, "The target names. It will format all default targets if this parameter is not specified.", + "e.g.", + " xmake format target1 target2 ..." , values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end } } } |
