@@ -83,8 +83,6 @@ def main():
8383 '--repo' , help = "The Github repo to be reformatted" , type = str )
8484 parser .add_argument (
8585 '--dryrun' , help = "Only produce warnings" , action = 'store_true' )
86- parser .add_argument (
87- '--werror' , help = "Treat clang-format warnings as errors" , action = 'store_true' )
8886 args = parser .parse_args ()
8987
9088 # Check for supported clang-format version
@@ -121,15 +119,19 @@ def main():
121119 for ext in fileExtensions :
122120 files = files + (sorted (rootPath .rglob (ext )))
123121
124- dryrun = ''
122+ clang_format_cmd = [ CLANG_FORMAT ]
125123 if args .dryrun :
126- dryrun = "--dry-run"
124+ clang_format_cmd .append ('--Werror' )
125+ clang_format_cmd .append ('--dry-run' )
126+
127+ clang_format_cmd = clang_format_cmd + ['-i' , '--style=file' ]
128+ print (clang_format_cmd )
127129 for file in files :
128130
129131 if any (p in file for p in dirs ):
130132
131133 totalFiles = totalFiles + 1
132- formatResult = subprocess .run ([ CLANG_FORMAT , '--Werror' , dryrun , '-i' , '--style=file' , file ], capture_output = True , encoding = 'utf-8' )
134+ formatResult = subprocess .run (clang_format_cmd + [ file ], capture_output = True , encoding = 'utf-8' )
133135 if formatResult .returncode != 0 :
134136 formattingCorrect = False
135137 totalWarnings = totalWarnings + 1
@@ -142,7 +144,7 @@ def main():
142144 # Only warn for now
143145 warn ("Formatting for one or more SilKit source code files not correct.!" )
144146 warn ("Please format your source code properly using the SilKit .clang-format config file!" )
145- ret_code = 64 if args .werror else 0
147+ ret_code = 64 if args .dryrun else 0
146148 exit (ret_code )
147149
148150 info ("All source code files properly formatted!" )
0 commit comments