]> Sergey Matveev's repositories - path-extractor.git/blobdiff - extractor.go
First try for linenumbers
[path-extractor.git] / extractor.go
index ac819dc0081fdfe3cd5fb1ac5b7b74c093697930..2a3b2cd5723d89593b5782e6782fa768b495c596 100644 (file)
@@ -1,6 +1,11 @@
 package pathextractor
 
 import "regexp"
+import "fmt"
+
+type MatchOptions struct {
+       format string
+}
 
 func pathExtractor(input string) [][][]byte {
        surroundRegex := "[^][ \\t:'\"]*"
@@ -25,10 +30,11 @@ func postProcess(input string) string {
        return input
 }
 
-func GetAllMatches(input string) []string {
+func GetAllMatches(input string, options MatchOptions) []string {
        matches := [][][]byte{}
        result := []string{}
        s := string("")
+       // print(input)
        matches = pathExtractor(input)
        for _, match := range matches {
                s = string(match[1])
@@ -38,7 +44,11 @@ func GetAllMatches(input string) []string {
                if isGitPath(s) {
                        s = replaceGitPath(s)
                }
-               result = append(result, postProcess(s))
+               s = postProcess(s)
+               if options.format == "ackmate" {
+                       s = fmt.Sprint(s, ":45")
+               }
+               result = append(result, s)
        }
        return result
 }