diff options
| author | Paul Buetow <git@mx.buetow.org> | 2021-02-05 09:02:14 +0000 |
|---|---|---|
| committer | Paul Buetow <git@mx.buetow.org> | 2021-02-05 09:02:14 +0000 |
| commit | 18a4de2bb288d44c4e5a7560fced7a15e9a6469d (patch) | |
| tree | d7a570ae5e9209a175aecef527e56e69d6879bce /cmd | |
| parent | a40e3c5c01d0b33f23c53eba1276cf244e4d060b (diff) | |
add --max, --before, --after switches to dtail and dgrep commands
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/dgrep/main.go | 7 | ||||
| -rw-r--r-- | cmd/dtail/main.go | 9 |
2 files changed, 13 insertions, 3 deletions
diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 4da1bb3..4a6790b 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -36,12 +36,17 @@ func main() { flag.IntVar(&sshPort, "port", 2222, "SSH server port") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") flag.StringVar(&args.PrivateKeyPathFile, "key", "", "Path to private key") - flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression") flag.StringVar(&args.ServersStr, "servers", "", "Remote servers to connect") flag.StringVar(&args.UserName, "user", userName, "Your system user name") 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") 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.Parse() diff --git a/cmd/dtail/main.go b/cmd/dtail/main.go index f2a039f..1930483 100644 --- a/cmd/dtail/main.go +++ b/cmd/dtail/main.go @@ -50,14 +50,19 @@ func main() { flag.IntVar(&sshPort, "port", 2222, "SSH server port") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") flag.StringVar(&args.PrivateKeyPathFile, "key", "", "Path to private key") - flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression") flag.StringVar(&args.ServersStr, "servers", "", "Remote servers to connect") flag.StringVar(&args.UserName, "user", userName, "Your system user name") flag.StringVar(&args.What, "files", "", "File(s) to read") flag.StringVar(&cfgFile, "cfg", "", "Config file path") - flag.StringVar(&grep, "grep", "", "Alias for -regex") flag.StringVar(&queryStr, "query", "", "Map reduce query") + // Context awareness. + flag.StringVar(&args.LineContext.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.Parse() if grep != "" { |
