feat: Add IngoreCase support
This commit is contained in:
@@ -14,8 +14,9 @@ import (
|
|||||||
// Panics and shows info if arguments are invalid
|
// Panics and shows info if arguments are invalid
|
||||||
func ProcessConsoleArguments() (*models.GrepConfigInternal, error) {
|
func ProcessConsoleArguments() (*models.GrepConfigInternal, error) {
|
||||||
var args struct {
|
var args struct {
|
||||||
Pattern string `arg:"positional" help:"Regex for lines to match"`
|
Pattern string `arg:"positional" help:"Regex for lines to match"`
|
||||||
Path string `arg:"positional" default:".*" help:"extra RegEx for paths to match"`
|
Path string `arg:"positional" default:".*" help:"extra RegEx for paths to match"`
|
||||||
|
IgnoreCase bool `arg:"-i" help:"ignore case distinctions in patterns and data"`
|
||||||
}
|
}
|
||||||
arg.MustParse(&args)
|
arg.MustParse(&args)
|
||||||
|
|
||||||
@@ -31,6 +32,9 @@ func ProcessConsoleArguments() (*models.GrepConfigInternal, error) {
|
|||||||
return nil, fmt.Errorf("unable to compile path pattern Regexp: %v", args.Path)
|
return nil, fmt.Errorf("unable to compile path pattern Regexp: %v", args.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if args.IgnoreCase {
|
||||||
|
args.Pattern = "(?i)" + args.Pattern
|
||||||
|
}
|
||||||
res.TextPattern, err = regexp.Compile(args.Pattern)
|
res.TextPattern, err = regexp.Compile(args.Pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to compile text pattern Regexp: %v", args.Pattern)
|
return nil, fmt.Errorf("unable to compile text pattern Regexp: %v", args.Pattern)
|
||||||
|
|||||||
Reference in New Issue
Block a user