X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=extractor.go;h=2a3b2cd5723d89593b5782e6782fa768b495c596;hb=10f0b99e4b320a2beb819c7dc40423041b039f31;hp=ac819dc0081fdfe3cd5fb1ac5b7b74c093697930;hpb=feba31d0851fee86d73575955c5f1806094bc59a;p=path-extractor.git diff --git a/extractor.go b/extractor.go index ac819dc..2a3b2cd 100644 --- a/extractor.go +++ b/extractor.go @@ -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 }