diff options
| author | A2va <[email protected]> | 2022-12-02 18:22:30 +0100 |
|---|---|---|
| committer | A2va <[email protected]> | 2022-12-02 18:22:30 +0100 |
| commit | 8096de60f4aac3fa3fa69de9e399f3a148203b4a (patch) | |
| tree | e25f58c88b67dfd600252e968f5a7a7406d710b9 /xmake/plugins/format/main.lua | |
| parent | df25bc8dfac8cbf690f6dff8dd263421a7ca795a (diff) | |
Improve file argument
Diffstat (limited to 'xmake/plugins/format/main.lua')
| -rw-r--r-- | xmake/plugins/format/main.lua | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua index 17ce73066..add8a7663 100644 --- a/xmake/plugins/format/main.lua +++ b/xmake/plugins/format/main.lua @@ -73,7 +73,26 @@ function main() -- set file to format if option.get("file") then - table.insert(argv, option.get("file")) + -- list of files/path to format + local files = option.get("file"):split(" ") + for _, f in ipairs(files) do + local p = path.join(project, f) + for _, filepath in ipairs(os.files(p)) do + table.insert(argv, filepath) + end + end + else + -- format all source files of all targets + for targetname, target in pairs(project.targets()) do + -- source files + for _, source in ipairs(target:sourcefiles()) do + table.insert(argv, path.join(projectdir,source)) + end + -- header files + for _, header in ipairs(target:sourcefiles()) do + table.insert(argv, path.join(projectdir,header)) + end + end end -- format files |
