diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2021-10-15 12:38:39 +0300 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2021-10-15 12:38:39 +0300 |
| commit | 55ba72efa4e5d2363f8e0c2cf729c596e760e1c3 (patch) | |
| tree | 72618e384626d9fc368994e3f24be9e9892d0610 /internal/clients/grepclient.go | |
| parent | dccbee7dc355438d87baff45e054848e508b004d (diff) | |
| parent | d3549a3316a9917520ab5e6b0cd7b1846c59ad4b (diff) | |
merge from github.com/snonux/dtail
Diffstat (limited to 'internal/clients/grepclient.go')
| -rw-r--r-- | internal/clients/grepclient.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/internal/clients/grepclient.go b/internal/clients/grepclient.go index 4024083..7521c67 100644 --- a/internal/clients/grepclient.go +++ b/internal/clients/grepclient.go @@ -7,16 +7,19 @@ import ( "strings" "github.com/mimecast/dtail/internal/clients/handlers" + "github.com/mimecast/dtail/internal/config" + "github.com/mimecast/dtail/internal/io/dlog" "github.com/mimecast/dtail/internal/omode" ) -// GrepClient searches a remote file for all lines matching a regular expression. Only the matching lines are displayed. +// GrepClient searches a remote file for all lines matching a regular +// expression. Only the matching lines are displayed. type GrepClient struct { baseClient } // NewGrepClient creates a new grep client. -func NewGrepClient(args Args) (*GrepClient, error) { +func NewGrepClient(args config.Args) (*GrepClient, error) { if args.RegexStr == "" { return nil, errors.New("No regex specified, use '-regex' flag") } @@ -32,7 +35,6 @@ func NewGrepClient(args Args) (*GrepClient, error) { c.init() c.makeConnections(c) - return &c, nil } @@ -41,8 +43,13 @@ func (c GrepClient) makeHandler(server string) handlers.Handler { } func (c GrepClient) makeCommands() (commands []string) { + regex, err := c.Regex.Serialize() + if err != nil { + dlog.Client.FatalPanic(err) + } for _, file := range strings.Split(c.What, ",") { - commands = append(commands, fmt.Sprintf("%s %s %s", c.Mode.String(), file, c.Regex.Serialize())) + commands = append(commands, fmt.Sprintf("%s:%s %s %s", + c.Mode.String(), c.Args.SerializeOptions(), file, regex)) } return } |
