Skip to content

Commit

Permalink
Adds support for multiple patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
tomnomnom committed Sep 16, 2018
1 parent 5514050 commit b5d868d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
36 changes: 35 additions & 1 deletion examples/takeovers.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
{
"flags": "-HnriE",
"pattern": "(There is no app configured at that hostname|NoSuchBucket|No Such Account|You're Almost There|a GitHub Pages site here|this shop is currently unavailable|There's nothing here|The request could not be satisfied|project not found|Your CNAME settings|InvalidBucketName|PermanentRedirect|The specified bucket does not exist|Repository not found|Bad Request: ERROR: The request could not be satisfied|Sorry, We Couldn't Find That Page|Fastly error: unknown domain:|The feed has not been found.|The thing you were looking for is no longer here, or never was|Please renew your subscription|There isn't a Github Pages site here.|We could not find what you're looking for.|No settings were found for this company:|No such app|is not a registered InCloud YouTrack|Unrecognized domain|Sorry, this shop is currently unavailable.|You are being redirected|project not found|The requested URL was not found on this server.|This UserVoice subdomain is currently available!|Do you want to register|Help Center Closed)"
"patterns": [
"There is no app configured at that hostname",
"NoSuchBucket",
"No Such Account",
"You're Almost There",
"a GitHub Pages site here",
"this shop is currently unavailable",
"There's nothing here",
"The request could not be satisfied",
"project not found",
"Your CNAME settings",
"InvalidBucketName",
"PermanentRedirect",
"The specified bucket does not exist",
"Repository not found",
"Bad Request: ERROR: The request could not be satisfied",
"Sorry, We Couldn't Find That Page",
"Fastly error: unknown domain:",
"The feed has not been found.",
"The thing you were looking for is no longer here, or never was",
"Please renew your subscription",
"There isn't a Github Pages site here.",
"We could not find what you're looking for.",
"No settings were found for this company:",
"No such app",
"is not a registered InCloud YouTrack",
"Unrecognized domain",
"Sorry, this shop is currently unavailable.",
"You are being redirected",
"project not found",
"The requested URL was not found on this server.",
"This UserVoice subdomain is currently available!",
"Do you want to register",
"Help Center Closed"
]
}

15 changes: 11 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
"os"
"os/exec"
"os/user"
"strings"
)

type pattern struct {
Flags string `json:"flags"`
Pattern string `json:"pattern"`
Flags string `json:"flags"`
Pattern string `json:"pattern"`
Patterns []string `json:"patterns"`
}

func main() {
Expand Down Expand Up @@ -47,8 +49,13 @@ func main() {
}

if pat.Pattern == "" {
fmt.Fprintf(os.Stderr, "pattern file '%s' contains no pattern\n", filename)
return
// check for multiple patterns
if len(pat.Patterns) == 0 {
fmt.Fprintf(os.Stderr, "pattern file '%s' contains no pattern(s)\n", filename)
return
}

pat.Pattern = "(" + strings.Join(pat.Patterns, "|") + ")"
}

cmd := exec.Command("grep", "--color", pat.Flags, pat.Pattern, files)
Expand Down

0 comments on commit b5d868d

Please sign in to comment.