Started working on line number flag
This commit is contained in:
@@ -27,6 +27,7 @@ func main() {
|
||||
printMatchesFlag := flag.Bool("p", false, "Prints start and end index of each match. Can only be used with '-t' for multi-line mode.")
|
||||
caseInsensitiveFlag := flag.Bool("i", false, "Case-insensitive. Disregard the case of all characters.")
|
||||
recursiveFlag := flag.Bool("r", false, "Recursively search all files in the given directory.")
|
||||
lineNumFlag := flag.Bool("n", false, "For each line with a match, print the line number. Implies -l.")
|
||||
matchNum := flag.Int("m", 0, "Print the match with the given index. Eg. -m 3 prints the third match.")
|
||||
substituteText := flag.String("s", "", "Substitute the contents of each match with the given string. Overrides -o and -v")
|
||||
flag.Parse()
|
||||
@@ -110,9 +111,6 @@ func main() {
|
||||
reader := bufio.NewReader(inputFile)
|
||||
linesRead = false
|
||||
for true {
|
||||
if !(*lineFlag) && (!*onlyFlag) {
|
||||
color.New(color.FgMagenta).Fprintf(out, "%s: ", inputFile.Name()) // The filename should be printed for every line, _except_ if we're not printing every line. This is the case with the lineFlag and onlyFlag
|
||||
}
|
||||
if linesRead {
|
||||
break
|
||||
}
|
||||
|
Reference in New Issue
Block a user