Skip to content

Commit

Permalink
#59 new cli flag -l for column-separation in output textfile (to gene…
Browse files Browse the repository at this point in the history
…rate csvs etc) (#60)

* chore (.gitignore): ignore .vscode folder and any *.code-workspace files

* clean (toputils.go): consolidate 1024-related constants used in Psize() into kibibytes, mebibytes, kibibytes which are well-known, human-readable units of measurement

* clean (toputils.go): neutral cleanups in Psize() to make it more readable

  - the if-else structure was not really needed and it has been simplified to use plain 'ifs'
  - the "NA" case at the bottom would never be reached because all possible cases are already covered from a numerical perspective

* feat (cli flags): add new flag '-b' which causes all traffic to be printed in raw bytes

* clean (Psize unit tests): refactor the test harness to have it employ t.Run() instead of raw tests

* clean (Psize unit tests): refactor the test harness to have it employ t.Run() instead of raw tests

* chore (.gitignore): ignore .vscode folder and any *.code-workspace files

* feat (new cli flag): add new flag '-b' to print traffic in raw bytes

  - consolidate 1024-related constants used in Psize() into kibibytes, mebibytes, kibibytes which are well-known, human-readable units of measurement
  - the if-else structure was not really needed and it has been simplified to use plain 'ifs'
  - the "NA" case at the bottom would never be reached because all possible cases are already covered from a numerical perspective
  - neutral cleanups in Psize() to make it more readable
  - refactor the test harness to have it employ t.Run() instead of raw tests

* clean (StartUI): trivial neutral cleanups

* refa (redraw mech): the redraw channel now records the reason behind each redraw

  with this change we can support the new '-r N' flag to exit upon refreshing N times

* feat (cli -r <max>): new flag "-r <max>" to specify the maximum number of times nats-top should refresh nats-stats before exiting

* feat (FetchStats()): extracted the fetching logic of MonitorStats() into a new method

* feat (MonitorStats()): simplify the method by having it invoke FetchStats() to fetch new nats-stats

* clean (FetchStats()): trivial simplification

* feat (cli flag -o): new flag to save a snapshot of the output directly into a file

* feat (cli flag '-o -'): passing '-o -' now prints the snapshot to the standard output

* sidefix (nats-top): replace log.Fatalf(...) that are followed by calls to usage() with calls to fmt.Fprintf(os.stderr, ...)

   this fix allows the usage message to be actually printed (old was: log.Fatalf(...) would cause the program to os.exit(1) before
   the usage message could actually be printed)

* clean (nats-top): remove method exitWithError() since it's not being used

* sideclean (refreshOptionHeader): use fmt.Print() instead of fmt.Printf()

* clean (nats-top): remove 'defaultHeader' as it was not being used anywhere

* clean (nats-top): move comments on the side to conserve vertical space

* clean (nats-top): move comments on the side to conserve vertical space

* revert (nats-top.go): revert a hunk that sneaked-in unintentionally in the previous few commits

* feat (file output formatter): turn the default "plain-text" formatter into its own separate formatter

* feat (generate csv): introduce new method generateParagraphCSV() tailor-made to generate .csv string-output

* doc (readme): update the usage message to have it mention the -l flag

Co-authored-by: Kyriakos Sidiropoulos <kyriakos.sidiropoulos@laerdal.com>
  • Loading branch information
dsidirop and ksidirop-laerdal authored Feb 16, 2022
1 parent 73e1dbc commit 696b065
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 88 deletions.
Loading

0 comments on commit 696b065

Please sign in to comment.