summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <git@mx.buetow.org>2021-02-05 09:32:52 +0000
committerPaul Buetow <git@mx.buetow.org>2021-02-05 09:32:52 +0000
commit6f093ff69c83526279b9f039aca079162c2b68d5 (patch)
tree8d695c5a100aae18ef90eeccc7ad2c075cfb39e5 /internal
parent18a4de2bb288d44c4e5a7560fced7a15e9a6469d (diff)
refactor
Diffstat (limited to 'internal')
-rw-r--r--internal/clients/args.go12
-rw-r--r--internal/clients/baseclient.go12
-rw-r--r--internal/lcontext/lcontext.go8
3 files changed, 17 insertions, 15 deletions
diff --git a/internal/clients/args.go b/internal/clients/args.go
index 67d2044..684dadd 100644
--- a/internal/clients/args.go
+++ b/internal/clients/args.go
@@ -1,22 +1,16 @@
package clients
import (
+ "github.com/mimecast/dtail/internal/lcontext"
"github.com/mimecast/dtail/internal/omode"
gossh "golang.org/x/crypto/ssh"
)
-// LineContext is here to help filtering out only specific lines.
-type LineContext struct {
- RegexStr string
- AfterContext int
- BeforeContext int
- MaxCount int
-}
-
// Args is a helper struct to summarize common client arguments.
type Args struct {
- LineContext
+ lcontext.LContext
+ RegexStr string
Mode omode.Mode
ServersStr string
UserName string
diff --git a/internal/clients/baseclient.go b/internal/clients/baseclient.go
index 0bdd62e..f83fcfd 100644
--- a/internal/clients/baseclient.go
+++ b/internal/clients/baseclient.go
@@ -126,14 +126,14 @@ func (c *baseClient) makeCommandOptions() map[string]string {
if c.Args.Quiet {
options["quiet"] = fmt.Sprintf("%v", c.Args.Quiet)
}
- if c.Args.LineContext.MaxCount != 0 {
- options["max"] = fmt.Sprintf("%d", c.Args.LineContext.MaxCount)
+ if c.Args.LContext.MaxCount != 0 {
+ options["max"] = fmt.Sprintf("%d", c.Args.LContext.MaxCount)
}
- if c.Args.LineContext.BeforeContext != 0 {
- options["before"] = fmt.Sprintf("%d", c.Args.LineContext.BeforeContext)
+ if c.Args.LContext.BeforeContext != 0 {
+ options["before"] = fmt.Sprintf("%d", c.Args.LContext.BeforeContext)
}
- if c.Args.LineContext.AfterContext != 0 {
- options["after"] = fmt.Sprintf("%d", c.Args.LineContext.AfterContext)
+ if c.Args.LContext.AfterContext != 0 {
+ options["after"] = fmt.Sprintf("%d", c.Args.LContext.AfterContext)
}
return options
diff --git a/internal/lcontext/lcontext.go b/internal/lcontext/lcontext.go
new file mode 100644
index 0000000..bd51d94
--- /dev/null
+++ b/internal/lcontext/lcontext.go
@@ -0,0 +1,8 @@
+package lcontext
+
+// LContext stands for line context and is here to help filtering out only specific lines.
+type LContext struct {
+ AfterContext int
+ BeforeContext int
+ MaxCount int
+}