Merge pull request #14 from thewtex/option-compatibility

Option compatibility
This commit is contained in:
Matt McCormick 2015-01-20 07:53:48 -05:00
commit 5132f338fd
3 changed files with 35 additions and 6 deletions

@ -115,8 +115,13 @@ if(BUILD_TESTING)
COMMAND tmux-mem-cpu-load --graph_lines -2 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 set_tests_properties(usage
invalid_status_interval invalid_status_interval
invalid_graph_lines invalid_graph_lines
old_option_specification
PROPERTIES WILL_FAIL TRUE) PROPERTIES WILL_FAIL TRUE)
endif() endif()

@ -86,18 +86,34 @@ Edit ``$HOME/.tmux.conf`` to display the program's output in *status-left* or
*status-right*. For example:: *status-right*. For example::
set -g status-interval 2 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. 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 defaults to 10. This can, for instance, be set to the number of cores in a
multi-core system. 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 <value>, --interval <value>
Set tmux status refresh interval in seconds. Default: 1 second
-g <value>, --graph-lines <value>
Set how many lines should be drawn in a graph. Default: 10
Authors
=======
Matt McCormick (thewtex) <matt@mmmccormick.com> Matt McCormick (thewtex) <matt@mmmccormick.com>

@ -155,10 +155,18 @@ int main( int argc, char** argv )
return EXIT_FAILURE; return EXIT_FAILURE;
break; break;
default: default:
std::cout << "?? getopt returned character code 0 " << c << std::endl; std::cerr << "?? getopt returned character code 0 " << c << std::endl;
return EXIT_FAILURE; 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 ) << ' ' std::cout << mem_string( use_colors ) << ' '
<< cpu_string( cpu_usage_delay, graph_lines, use_colors ) << ' ' << cpu_string( cpu_usage_delay, graph_lines, use_colors ) << ' '