@@ -261,6 +261,27 @@ def flush_porting_log(tmpfile, porting_filename):
261
261
# (so retrying compile will succeed)
262
262
os .rmdir (lockfile )
263
263
264
+ class HelpAction (argparse .Action ):
265
+ def __init__ (self , option_strings , dest , ** kwargs ):
266
+ super ().__init__ (option_strings , dest , nargs = 0 , ** kwargs )
267
+
268
+ def __call__ (self , parser , namespace , values , option_string = None ):
269
+ self .print_help ()
270
+ parser .exit ()
271
+
272
+ class WarnHelpAction (HelpAction ):
273
+ def print_help (self ):
274
+ print ('''Tags accepted by --warn and --nowarn:''' )
275
+ by_ignored = {True : [], False : []}
276
+ for tag in sorted (messages .warnings ):
277
+ by_ignored [warning_is_ignored (tag )].append (tag )
278
+ print (' Enabled by default:' )
279
+ for tag in by_ignored [False ]:
280
+ print (f' { tag } ' )
281
+ print (' Disabled by default:' )
282
+ for tag in by_ignored [True ]:
283
+ print (f' { tag } ' )
284
+
264
285
def main (argv ):
265
286
# DML files must be utf8, but are generally opened without specifying
266
287
# the 'encoding' arg. This works only if utf8_mode is enabled.
@@ -357,6 +378,8 @@ def main(argv):
357
378
default = [],
358
379
help = 'disable warning TAG' )
359
380
381
+ parser .add_argument ('--help-warn' , action = WarnHelpAction ,
382
+ help = 'List warning tags available for --warn/--nowarn' )
360
383
# <dt>--werror</dt>
361
384
# <dd>Turn all warnings into errors.</dd>
362
385
parser .add_argument ('--werror' , action = 'store_true' ,
0 commit comments