diff options
| author | Paul Buetow <git@mx.buetow.org> | 2021-02-05 09:32:52 +0000 |
|---|---|---|
| committer | Paul Buetow <git@mx.buetow.org> | 2021-02-05 09:32:52 +0000 |
| commit | 6f093ff69c83526279b9f039aca079162c2b68d5 (patch) | |
| tree | 8d695c5a100aae18ef90eeccc7ad2c075cfb39e5 /cmd | |
| parent | 18a4de2bb288d44c4e5a7560fced7a15e9a6469d (diff) | |
refactor
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/dgrep/main.go | 18 | ||||
| -rw-r--r-- | cmd/dtail/main.go | 10 |
2 files changed, 14 insertions, 14 deletions
diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 4a6790b..123d061 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -41,15 +41,19 @@ func main() { flag.StringVar(&args.What, "files", "", "File(s) to read") flag.StringVar(&cfgFile, "cfg", "", "Config file path") - // Context awareness. - flag.StringVar(&args.LineContext.RegexStr, "regex", ".", "Regular expression") + // Line context awareness. + flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression") flag.StringVar(&grep, "grep", "", "Alias for -regex") - flag.IntVar(&args.LineContext.BeforeContext, "before", 0, "Print lines of leading context before matching lines") - flag.IntVar(&args.LineContext.AfterContext, "after", 0, "Print lines of trailing context after matching lines") - flag.IntVar(&args.LineContext.MaxCount, "max", 0, "Stop reading file after NUM matching lines") + flag.IntVar(&args.LContext.BeforeContext, "before", 0, "Print lines of leading context before matching lines") + flag.IntVar(&args.LContext.AfterContext, "after", 0, "Print lines of trailing context after matching lines") + flag.IntVar(&args.LContext.MaxCount, "max", 0, "Stop reading file after NUM matching lines") flag.Parse() + if grep != "" { + args.RegexStr = grep + } + config.Read(cfgFile, sshPort) color.Colored = !noColor @@ -63,10 +67,6 @@ func main() { Quiet: args.Quiet, }) - if grep != "" { - args.RegexStr = grep - } - client, err := clients.NewGrepClient(args) if err != nil { panic(err) diff --git a/cmd/dtail/main.go b/cmd/dtail/main.go index 1930483..2639b4b 100644 --- a/cmd/dtail/main.go +++ b/cmd/dtail/main.go @@ -56,12 +56,12 @@ func main() { flag.StringVar(&cfgFile, "cfg", "", "Config file path") flag.StringVar(&queryStr, "query", "", "Map reduce query") - // Context awareness. - flag.StringVar(&args.LineContext.RegexStr, "regex", ".", "Regular expression") + // Line context awareness. + flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression") flag.StringVar(&grep, "grep", "", "Alias for -regex") - flag.IntVar(&args.LineContext.BeforeContext, "before", 0, "Print lines of leading context before matching lines") - flag.IntVar(&args.LineContext.AfterContext, "after", 0, "Print lines of trailing context after matching lines") - flag.IntVar(&args.LineContext.MaxCount, "max", 0, "Stop reading file after NUM matching lines") + flag.IntVar(&args.LContext.BeforeContext, "before", 0, "Print lines of leading context before matching lines") + flag.IntVar(&args.LContext.AfterContext, "after", 0, "Print lines of trailing context after matching lines") + flag.IntVar(&args.LContext.MaxCount, "max", 0, "Stop reading file after NUM matching lines") flag.Parse() |
