summaryrefslogtreecommitdiff
path: root/xmake/plugins/format/main.lua
diff options
context:
space:
mode:
authorjj683 <[email protected]>2024-11-30 12:49:55 +0100
committerjj683 <[email protected]>2024-11-30 12:49:55 +0100
commit644009926af1ad90bfcc47cf8bd625813c19b9c1 (patch)
tree54f94151bb65e3b524c6ee815750d467e789f1ad /xmake/plugins/format/main.lua
parent2f1213a70b2ea1be2097c7f2bd7b4fc85a861b80 (diff)
Add Werror and dry-run flags for clang-format
Diffstat (limited to 'xmake/plugins/format/main.lua')
-rw-r--r--xmake/plugins/format/main.lua19
1 files changed, 17 insertions, 2 deletions
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua
index 52c64d3b0..7f807f412 100644
--- a/xmake/plugins/format/main.lua
+++ b/xmake/plugins/format/main.lua
@@ -148,8 +148,23 @@ function main()
table.insert(argv, "--style=" .. option.get("style"))
end
- -- inplace flag
- table.insert(argv, "-i")
+ if option.get("dry-run") then
+ -- do not make any changes, just show the files that would be formatted
+ table.insert(argv, "--dry-run")
+ else
+ -- inplace flag
+ table.insert(argv, "-i")
+ end
+
+ -- changes formatting warnings to errors
+ if option.get("error") then
+ table.insert(argv, "--Werror")
+ end
+
+ -- print verbose information
+ if option.get("verbose") then
+ table.insert(argv, "--verbose")
+ end
local targetname
local group_pattern = option.get("group")