Option to include the first line of any searched file in the output
I'm frequently searching CSV files with 20-30 columns, and when there's a hit it can be hard to know what the columns are. An option to print the first line of a file (either always, or only if that file had a match to the pattern) in addition to any hits would be nice.
Are you using --cvs-per-line for this?
In other words: I guess you'd only want the first line if it is a CSV file, right?
Or are you searching pure on text?
I didn't know about/wasn't using --csv-per-line. I guess I generally know it's they're CSV files, but for some reason I'm thinking of the print-first-line as a general option.
Then I guess you'd only want that printed if there is actually a match anywhere in the file. Not just for all files that are being searched, right?
How about a --accept-first[=N] option. This would accept the first N lines as matches (with N being 1 if specified as a flag).
This would then always show the first line of any file inspected.
@MasterDuke17
So I'm thinking of adding:
--always-first[=N]
This will basically not call the matcher for the first N lines (with N defaulting to 1), but will always produce them as if they matched.
--also-first[=N]
This is basically a special type of context: if there is a match, it will produce the first N (with N defaulting to 1) as context.
Would that make sense?
Yep, that's pretty much exactly what I was thinking.
Implemented with 0.3.9 so closing