diff options
| author | A2va <[email protected]> | 2022-11-11 18:54:32 +0100 |
|---|---|---|
| committer | A2va <[email protected]> | 2022-11-11 18:54:32 +0100 |
| commit | d3b7498679fd2c1234c118a056a84f8aa3fa04d3 (patch) | |
| tree | b9c4c88787e629c541d35ef3b6990c48f7cdbe56 /xmake/plugins/format | |
| parent | 808290756e24ce7ee70d5897477c5b20bd751981 (diff) | |
Invoke clang-format
Diffstat (limited to 'xmake/plugins/format')
| -rw-r--r-- | xmake/plugins/format/main.lua | 11 | ||||
| -rw-r--r-- | xmake/plugins/format/xmake.lua | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua index a3973fee9..79561daba 100644 --- a/xmake/plugins/format/main.lua +++ b/xmake/plugins/format/main.lua @@ -69,5 +69,16 @@ function main() table.insert(argv, "--style=" .. option.get("style")) end + -- inplace flag + table.insert(argv,"-i") + -- set file to format + if option.get("file") then + table.insert(argv, option.get("file")) + end + + -- format files + os.vrunv(clang_format.program, argv, {curdir = project.directory()}) + cprint("${color.success}formatting complete") + os.setenvs(oldenvs) end diff --git a/xmake/plugins/format/xmake.lua b/xmake/plugins/format/xmake.lua index 980795b60..3b3e2bec3 100644 --- a/xmake/plugins/format/xmake.lua +++ b/xmake/plugins/format/xmake.lua @@ -40,7 +40,8 @@ task("format") { {'s', "style", "kv", nil, "Set the path of.clang-format file, a coding style".. "(LLVM, Google, Chromium, Mozilla, WebKit) or key value string" } - , {nil, "create-style", "kv", nil, "Create a .clang-format file from a coding style" } + , {nil, "create-style", "kv", nil, "Create a .clang-format file from a coding style" }, + {'f', "file", "v", "*.cpp *.h *.hpp", "Set file path or glob pattern"} } } |
