Commits

Bernhard Leiner committed 06e52f3

add --nobreak command line option (ack feature)

Comments (0)

Files changed (3)

         do_colors=True,
         match_color_str=None,
         filename_color_str=None,
+        do_break=True,
         prefix_filename_to_file_matches=True,
         show_column_of_first_match=False,
         ncontext_before=0,
                 # just show the matches without considering context
                 for match in matches:
                     output_formatter.matching_line(match)
-            output_formatter.end_matches_in_file(filepath)
+
+            if do_break:
+                output_formatter.end_matches_in_file(filepath)
 
 
 def _pattern_has_uppercase(pattern):
                 do_colors=options.do_colors,
                 match_color_str=options.color_match,
                 filename_color_str=options.color_filename,
+                do_break=options.do_break,
                 prefix_filename_to_file_matches=options.prefix_filename,
                 show_column_of_first_match=options.show_column,
                 ncontext_before=ncontext_before,
     group_output.add_option('--color-filename', metavar='FORE,BACK,STYLE',
         action='store', dest='color_filename',
         help='Set the color for emitted filenames')
+    group_output.add_option('--nobreak',
+        action='store_false', dest='do_break', default=True,
+        help='Print no break between results from different files')
     optparser.add_option_group(group_output)
 
     group_filefinding = optparse.OptionGroup(optparser, 'File finding')

test/test_pssmain.py

                     [   ('MATCH', (4, [(18, 21)])),
                         ('MATCH', (14, [(15, 18)]))]))
 
+    def test_no_break(self):
+        # same test as above but with --nobreak
+        self._run_main(['abc', '--ada', '--nobreak'])
+        self.assertEqual(self.of.output,
+                self._gen_outputs_in_file(
+                    'testdir1/subdir1/someada.adb',
+                    [   ('MATCH', (4, [(18, 21)])),
+                        ('MATCH', (14, [(15, 18)]))])
+                        [:-1]) # strip off END_MATCHES
+
     def test_context_separate(self):
         # context set to +/-3, so it's not "merged" between the two matches
         # and stays separate, with a context separator