@@ -339,10 +339,9 @@ def parse_options(
339
339
"-D" ,
340
340
"--dictionary" ,
341
341
action = "append" ,
342
- help = "custom dictionary file that contains spelling "
343
- "corrections. If this flag is not specified or "
344
- 'equals "-" then the default dictionary is used. '
345
- "This option can be specified multiple times." ,
342
+ help = "comma-separated list of custom dictionary files that "
343
+ "contain spelling corrections. If this flag is not specified "
344
+ 'or equals "-" then the default dictionary is used.' ,
346
345
)
347
346
builtin_opts = "\n - " .join (
348
347
["" ] + [f"{ d [0 ]!r} { d [1 ]} " for d in _builtin_dictionaries ]
@@ -372,26 +371,26 @@ def parse_options(
372
371
"-I" ,
373
372
"--ignore-words" ,
374
373
action = "append" ,
375
- metavar = "FILE " ,
376
- help = "file that contains words that will be ignored "
377
- "by codespell. File must contain 1 word per line. "
378
- " Words are case sensitive based on how they are "
379
- "written in the dictionary file" ,
374
+ metavar = "FILES " ,
375
+ help = "comma-separated list of files that contain "
376
+ "words to be ignored by codespell. Files must contain "
377
+ "1 word per line. Words are case sensitive based on "
378
+ "how they are written in the dictionary file. " ,
380
379
)
381
380
parser .add_argument (
382
381
"-L" ,
383
382
"--ignore-words-list" ,
384
383
action = "append" ,
385
384
metavar = "WORDS" ,
386
- help = "comma separated list of words to be ignored "
385
+ help = "comma- separated list of words to be ignored "
387
386
"by codespell. Words are case sensitive based on "
388
- "how they are written in the dictionary file" ,
387
+ "how they are written in the dictionary file. " ,
389
388
)
390
389
parser .add_argument (
391
390
"--uri-ignore-words-list" ,
392
391
action = "append" ,
393
392
metavar = "WORDS" ,
394
- help = "comma separated list of words to be ignored "
393
+ help = "comma- separated list of words to be ignored "
395
394
"by codespell in URIs and emails only. Words are "
396
395
"case sensitive based on how they are written in "
397
396
'the dictionary file. If set to "*", all '
@@ -443,11 +442,13 @@ def parse_options(
443
442
parser .add_argument (
444
443
"-x" ,
445
444
"--exclude-file" ,
445
+ action = "append" ,
446
446
type = str ,
447
- metavar = "FILE" ,
448
- help = "ignore whole lines that match those "
449
- "in the file FILE. The lines in FILE "
450
- "should match the to-be-excluded lines exactly" ,
447
+ metavar = "FILES" ,
448
+ help = "ignore whole lines that match those in "
449
+ "the comma-separated list of files EXCLUDE. "
450
+ "The lines in these files should match the "
451
+ "to-be-excluded lines exactly" ,
451
452
)
452
453
453
454
parser .add_argument (
@@ -984,6 +985,12 @@ def parse_file(
984
985
return bad_count
985
986
986
987
988
+ def flatten_comma_separated_arguments (
989
+ arguments : List (str ),
990
+ ) -> List (str ):
991
+ return [item for argument in arguments for item in argument .split ("," )]
992
+
993
+
987
994
def _script_main () -> int :
988
995
"""Wrap to main() for setuptools."""
989
996
return main (* sys .argv [1 :])
@@ -1028,8 +1035,8 @@ def main(*args: str) -> int:
1028
1035
else :
1029
1036
ignore_word_regex = None
1030
1037
1031
- ignore_words_files = options .ignore_words or []
1032
1038
ignore_words = parse_ignore_words_option (options .ignore_words_list )
1039
+ ignore_words_files = flatten_comma_separated_arguments (options .ignore_words )
1033
1040
for ignore_words_file in ignore_words_files :
1034
1041
if not os .path .isfile (ignore_words_file ):
1035
1042
print (
@@ -1052,10 +1059,7 @@ def main(*args: str) -> int:
1052
1059
return EX_USAGE
1053
1060
uri_ignore_words = parse_ignore_words_option (options .uri_ignore_words_list )
1054
1061
1055
- if options .dictionary :
1056
- dictionaries = options .dictionary
1057
- else :
1058
- dictionaries = ["-" ]
1062
+ dictionaries = flatten_comma_separated_arguments (options .dictionary ) or ["-" ]
1059
1063
use_dictionaries = []
1060
1064
for dictionary in dictionaries :
1061
1065
if dictionary == "-" :
@@ -1118,8 +1122,9 @@ def main(*args: str) -> int:
1118
1122
context = (context_before , context_after )
1119
1123
1120
1124
exclude_lines : Set [str ] = set ()
1121
- if options .exclude_file :
1122
- build_exclude_hashes (options .exclude_file , exclude_lines )
1125
+ exclude_files = flatten_comma_separated_arguments (options .exclude_file )
1126
+ for exclude_file in exclude_files :
1127
+ build_exclude_hashes (exclude_file , exclude_lines )
1123
1128
1124
1129
file_opener = FileOpener (options .hard_encoding_detection , options .quiet_level )
1125
1130
0 commit comments