From 644009926af1ad90bfcc47cf8bd625813c19b9c1 Mon Sep 17 00:00:00 2001 From: jj683 Date: Sat, 30 Nov 2024 12:49:55 +0100 Subject: Add Werror and dry-run flags for clang-format --- xmake/plugins/format/main.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'xmake/plugins/format/main.lua') 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") -- cgit v1.3.1