-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support grep & grep -v feature
- Loading branch information
Showing
4 changed files
with
115 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cmd | ||
|
||
// Help template defines the format of the help message. | ||
var helpTemplate = `{{.Long | trim}} | ||
Usage: | ||
{{.CommandPath}} [flags] | ||
{{if .Runnable}} | ||
Flags: | ||
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}} | ||
` | ||
|
||
// Usage template defines the format of the usage message. | ||
var usageTemplate = `Usage: {{.CommandPath}} [flags]` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
package core | ||
|
||
import "regexp" | ||
|
||
func MatchLine(line, pattern string, inverse bool) (string, error) { | ||
regexPattern, err := regexp.Compile(pattern) | ||
if err != nil { | ||
return "", err | ||
} | ||
if regexPattern.MatchString(line) && !inverse { | ||
return line, nil | ||
} | ||
if !regexPattern.MatchString(line) && inverse { | ||
return line, nil | ||
} | ||
return "", nil | ||
} |