@@ -198,6 +198,12 @@ def parse_args():
198198 parser .add_argument ('--verbose' , '-v' , action = 'store_true' , default = False ,
199199 dest = 'verbose' , help = 'Make output verbose' )
200200
201+ parser .add_argument ('--first' , '-f' , action = 'store_true' , default = False ,
202+ dest = 'first' , help = 'Show only first occurrence of a mispelling' )
203+
204+ parser .add_argument ('--vim' , '-V' , action = 'store_true' , default = False ,
205+ dest = 'vim' , help = 'Output results in vim command format' )
206+
201207 parser .add_argument ('--dict' , '-d' , action = 'append' ,
202208 dest = 'dict' ,
203209 help = 'Add a dictionary (multiples allowed)' )
@@ -330,22 +336,26 @@ def main():
330336 if not args .miss :
331337 print ("\n Bad words\n " )
332338
333- prev = ""
334- bc = 0
335- for x in bad_words :
336- if x [0 ] == prev :
339+ previous_word = ""
340+
341+ for misspelled_word , found_file , line_num in bad_words :
342+
343+ if (misspelled_word != previous_word ):
344+ print ("\n " , misspelled_word ,":" , sep = '' )
345+
346+ if (misspelled_word == previous_word ) and args .first :
337347 sys .stderr .write ('.' )
338348 continue
339- print ("\n " , x [0 ], ": " , x [1 ], ", " , x [2 ], sep = '' , file = sys .stderr )
340- prev = x [0 ]
341- bc = bc + 1
342349
343- if not args .miss :
344- print ("" )
350+ if args .vim :
351+ print (" vim +" , line_num , " " , found_file , sep = '' , file = sys .stderr )
352+ else :
353+ print (" " , found_file , ", " , line_num , sep = '' , file = sys .stderr )
354+
355+ previous_word = misspelled_word
345356
346357 print ("" )
347- print (bc , "unknown words found" )
348- print (len (bad_words ), "instances" )
358+ print (len (bad_words ), "misspellings found" )
349359
350360 sys .exit (len (bad_words ))
351361
0 commit comments