From 1bfda9484a4b962a745a1d734a75ccfb13f5d5c1 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 19 Jan 2015 22:51:14 -0500 Subject: [PATCH 1/3] Detect old option specification fail informatively. Print the information message to std::cout so it gets printed on the tmux status line so users of 2.X know how to update their configuration. --- CMakeLists.txt | 5 +++++ tmux-mem-cpu-load.cc | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7686a8..e262b83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,8 +115,13 @@ if(BUILD_TESTING) COMMAND tmux-mem-cpu-load --graph_lines -2 ) + add_test(NAME old_option_specification + COMMAND tmux-mem-cpu-load 2 8 + ) + set_tests_properties(usage invalid_status_interval invalid_graph_lines + old_option_specification PROPERTIES WILL_FAIL TRUE) endif() diff --git a/tmux-mem-cpu-load.cc b/tmux-mem-cpu-load.cc index 737899a..556ae47 100644 --- a/tmux-mem-cpu-load.cc +++ b/tmux-mem-cpu-load.cc @@ -159,6 +159,14 @@ int main( int argc, char** argv ) return EXIT_FAILURE; } } + // Detect old option specification and return and error message. + if( argc > optind ) + { + std::cout << + "The interval and graph lines options are now specified with flags.\n\n"; + print_help(); + return EXIT_FAILURE; + } std::cout << mem_string( use_colors ) << ' ' << cpu_string( cpu_usage_delay, graph_lines, use_colors ) << ' ' From fa4a5b5c2b699aaa7809454e4ee063a44186e289 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 19 Jan 2015 22:52:04 -0500 Subject: [PATCH 2/3] Print error message to std::cerr. --- tmux-mem-cpu-load.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmux-mem-cpu-load.cc b/tmux-mem-cpu-load.cc index 556ae47..2937a39 100644 --- a/tmux-mem-cpu-load.cc +++ b/tmux-mem-cpu-load.cc @@ -155,7 +155,7 @@ int main( int argc, char** argv ) return EXIT_FAILURE; break; default: - std::cout << "?? getopt returned character code 0 " << c << std::endl; + std::cerr << "?? getopt returned character code 0 " << c << std::endl; return EXIT_FAILURE; } } From ea0e620a464580c1d5e8e72533e04a74882db784 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 19 Jan 2015 23:00:48 -0500 Subject: [PATCH 3/3] Update the README for new usage. --- README.rst | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 9cf0128..90d885d 100644 --- a/README.rst +++ b/README.rst @@ -86,18 +86,34 @@ Edit ``$HOME/.tmux.conf`` to display the program's output in *status-left* or *status-right*. For example:: set -g status-interval 2 - set -g status-left "#S #[fg=green,bg=black]#(tmux-mem-cpu-load --colors 2)#[default]" + set -g status-left "#S #[fg=green,bg=black]#(tmux-mem-cpu-load --colors --interval 2)#[default]" -Note that the first argument to `tmux-mem-cpu-load` should be the same number +Note that the *interval* argument to `tmux-mem-cpu-load` should be the same number of seconds that *status-interval* is set at. -An optional second argument is the number of bars in the bar graph, which +Another optional argument is the number of bars in the bar graph, which defaults to 10. This can, for instance, be set to the number of cores in a multi-core system. +The *colors* option will add graded colors for each of the measures. -Author -====== +The full usage:: + + Usage: tmux-mem-cpu-load [OPTIONS] + + Available options: + -h, --help + Prints this help message + --colors + Use tmux colors in output + -i , --interval + Set tmux status refresh interval in seconds. Default: 1 second + -g , --graph-lines + Set how many lines should be drawn in a graph. Default: 10 + + +Authors +======= Matt McCormick (thewtex)