Fixed bug where I checked if flag was enabled before calling flag.Parse()
This commit is contained in:
7
main.go
7
main.go
@@ -23,16 +23,17 @@ func main() {
|
||||
multiLineFlag := flag.Bool("t", false, "Multi-line mode. Treats newline just like any character.")
|
||||
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.")
|
||||
if *caseInsensitiveFlag {
|
||||
flagsToCompile = append(flagsToCompile, RE_CASE_INSENSITIVE)
|
||||
}
|
||||
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()
|
||||
|
||||
// These flags have to be passed to the Compile function
|
||||
if *multiLineFlag {
|
||||
flagsToCompile = append(flagsToCompile, RE_MULTILINE)
|
||||
}
|
||||
if *caseInsensitiveFlag {
|
||||
flagsToCompile = append(flagsToCompile, RE_CASE_INSENSITIVE)
|
||||
}
|
||||
|
||||
// -l and -o are mutually exclusive: -o overrides -l
|
||||
if *onlyFlag {
|
||||
|
Reference in New Issue
Block a user