From 2fce567d1daefaef73181260f6333ab69dfaefb1 Mon Sep 17 00:00:00 2001 From: "Kyriakos (Dominick) Sidiropoulos" Date: Thu, 26 May 2022 19:55:09 +0200 Subject: [PATCH] #69 new flag display subscriptions column - addendum for README.md (#71) * feat (display-subscriptions-column): add the '-u' shorthand for the long option '--display-subscriptions-column' and updated the README.md file accordingly to mention these new options Co-authored-by: Kyriakos Sidiropoulos --- .gitignore | 1 - nats-top.go | 9 ++++++--- readme.md | 10 +++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 891b313..dc47821 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,5 @@ _testmain.go /nats-top # VSCode - .vscode/** *.code-workspace diff --git a/nats-top.go b/nats-top.go index 1923681..452a042 100644 --- a/nats-top.go +++ b/nats-top.go @@ -29,7 +29,7 @@ var ( outputDelimiter = flag.String("l", "", "Specifies the delimiter to use for the output file when the '-o' parameter is used. By default this option is unset which means that standard grid-like plain-text output will be used.") displayRawBytes = flag.Bool("b", false, "Display traffic in raw bytes.") maxStatsRefreshes = flag.Int("r", -1, "Specifies the maximum number of times nats-top should refresh nats-stats before exiting.") - displaySubscriptionsColumn = flag.Bool("display-subscriptions-column", false, "Display subscriptions column upon launch.") + displaySubscriptionsColumn = false // Secure options httpsPort = flag.Int("ms", 0, "The NATS server secure monitoring port.") @@ -41,7 +41,7 @@ var ( const usageHelp = ` usage: nats-top [-s server] [-m http_port] [-ms https_port] [-n num_connections] [-d delay_secs] [-r max] [-o FILE] [-l DELIMITER] [-sort by] - [-cert FILE] [-key FILE] [-cacert FILE] [-k] [-b] [-v|--version] [-display-subscriptions-column] + [-cert FILE] [-key FILE] [-cacert FILE] [-k] [-b] [-v|--version] [-u|--display-subscriptions-column] ` @@ -53,6 +53,9 @@ func init() { flag.BoolVar(&showVersion, "v", false, "Same as --version.") flag.BoolVar(&showVersion, "version", false, "Show nats-top version.") + flag.BoolVar(&displaySubscriptionsColumn, "u", false, "Same as --display-subscriptions-column.") + flag.BoolVar(&displaySubscriptionsColumn, "display-subscriptions-column", false, "Display subscriptions-column upon launch.") + log.SetFlags(0) flag.Usage = usage flag.Parse() @@ -103,7 +106,7 @@ func main() { } engine.SortOpt = sortOpt - if *displaySubscriptionsColumn { + if displaySubscriptionsColumn { engine.DisplaySubs = true } diff --git a/readme.md b/readme.md index 7cd34de..fef5430 100644 --- a/readme.md +++ b/readme.md @@ -41,7 +41,7 @@ and releases of the binary are also [available](https://github.com/nats-io/nats- ``` usage: nats-top [-s server] [-m http_port] [-ms https_port] [-n num_connections] [-d delay_secs] [-r max] [-o FILE] [-l DELIMITER] [-sort by] - [-cert FILE] [-key FILE ][-cacert FILE] [-k] [-b] + [-cert FILE] [-key FILE ][-cacert FILE] [-k] [-b] [-v|--version] [-u|--display-subscriptions-column] ``` - `-m http_port`, `-ms https_port` @@ -84,6 +84,14 @@ usage: nats-top [-s server] [-m http_port] [-ms https_port] [-n num_connections] Displays traffic in raw bytes. +- `-v|--version` + + Displays the version of nats-top. + +- `-u|--display-subscriptions-column` + + Makes the subscriptions-column immediately visible upon launching nats-top. + ## Commands While in top view, it is possible to use the following commands: