From 9e1b63be3250661124babf270f8a13326ef0d2f0 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Thu, 16 Apr 2020 13:28:18 -0500 Subject: Closes #46, option to display network traffic as mbps. This can be set on the command line with --mbps, or toggled while running with `b` --- cmd/gotop/main.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/gotop/main.go b/cmd/gotop/main.go index 5dbcd3e..5728128 100644 --- a/cmd/gotop/main.go +++ b/cmd/gotop/main.go @@ -74,12 +74,13 @@ Options: -b, --battery Show battery level widget ('minimal' turns off). (DEPRECATED, use -l battery) -B, --bandwidth=bits Specify the number of bits per seconds. -l, --layout=NAME Name of layout spec file for the UI. Looks first in $XDG_CONFIG_HOME/gotop, then as a path. Use "-" to pipe. - -i, --interface=NAME Select network interface [default: all]. Several interfaces can be defined using comma separated values. Interfaces can also be ignored using ! + -i, --interface=NAME Select network interface [default: all]. Several interfaces can be defined using comma separated values. Interfaces can also be ignored using ! -x, --export=PORT Enable metrics for export on the specified port. - -X, --extensions=NAMES Enables the listed extensions. This is a comma-separated list without the .so suffix. The current and config directories will be searched. - --test Runs tests and exits with success/failure code - --print-paths List out the paths that gotop will look for gotop.conf, layouts, color schemes, and extensions - --print-keys Show the keyboard bindings + -X, --extensions=NAMES Enables the listed extensions. This is a comma-separated list without the .so suffix. The current and config directories will be searched. + --mbps Net widget shows mb(its)ps for RX/TX instead of scaled bytes per second. + --test Runs tests and exits with success/failure code. + --print-paths List out the paths that gotop will look for gotop.conf, layouts, color schemes, and extensions. + --print-keys Show the keyboard bindings. Built-in layouts: default @@ -184,6 +185,9 @@ Log files are stored in %s } conf.GraphHorizontalScale = scl } + if args["--mbps"].(bool) { + conf.Mbps = true + } if args["--print-paths"].(bool) { paths := make([]string, 0) for _, d := range conf.ConfigDir.QueryFolders(configdir.All) { @@ -308,6 +312,10 @@ func eventLoop(c gotop.Config, grid *layout.MyGrid) { ui.Render(item) } } + case "b": + if grid.Net != nil { + grid.Net.Mbps = !grid.Net.Mbps + } case "": ui.Render(grid) if statusbar { -- cgit v1.2.3