fast-cli icon indicating copy to clipboard operation
fast-cli copied to clipboard

Normalized output (allow an option for non-human readable output)

Open crozone opened this issue 5 years ago • 1 comments

Overview

An option for normalized output in bytes (aka a non-human readable form) would allow for easier machine processing of the output. For example, normalized results could be trivially plotted over time.

Currently the result is always printed in human readable form, which makes the magnitude of the numeric result change depending on its unit. Machine processing requires post-processing of the result in order to get it back into bps, which is cumbersome to do from the command line. The resultant line also includes additional whitespace prefixing, which makes processing in bash even more cumbersome.

Example

Example of current output:

$ fast-cli --simple
  47.19 Mbps

Example of normalized output:

$ fast-cli --simple --normalized
47190000

Workaround

Current workaround is to use numfmt (available in debian coreutils package):

$ fast-cli --simple | numfmt --from=auto --suffix=bps -d \n
47100000bps

However, this still includes a "bps" suffix which must be removed.

Changes

This would require parsing an additional argument, and adding an extra case in main.go: https://github.com/gesquive/fast-cli/blob/7d2b485ebf4e06b5959eb89e1eb4fceee33307e5/main.go#L161-L163

crozone avatar Nov 06 '19 06:11 crozone

Thanks for the suggestion. I'll think about including something like this in a future release

gesquive avatar Nov 11 '19 14:11 gesquive