Added option to disable colors.

Explanation option is disabled by default.
This commit is contained in:
Major Hayden 2007-06-06 15:31:48 +00:00
parent a4f7c5bbe0
commit beaeaf26e8

View file

@ -12,8 +12,9 @@ my %opt = (
"nogood" => 0, "nogood" => 0,
"noinfo" => 0, "noinfo" => 0,
"notitle" => 0, "notitle" => 0,
"noexplain" => 0, "withexplain" => 0,
"explainonly" => 0, "explainonly" => 0,
"nocolor" => 0,
); );
# Gather the options from the command line # Gather the options from the command line
@ -22,8 +23,9 @@ GetOptions(\%opt,
'nogood', 'nogood',
'noinfo', 'noinfo',
'notitle', 'notitle',
'noexplain', 'withexplain',
'explainonly', 'explainonly',
'nocolor',
'help', 'help',
); );
@ -43,17 +45,24 @@ sub usage {
" --nobad Remove negative/suggestion responses\n". " --nobad Remove negative/suggestion responses\n".
" --noinfo Remove informational responses\n". " --noinfo Remove informational responses\n".
" --notitle Remove section title headers\n". " --notitle Remove section title headers\n".
" --noexplain Remove verbose explanations\n". " --withexplain Add verbose explanations\n".
" --explainonly Provide only long text explanations, no bullets/titles\n". " --explainonly Provide only long text explanations, no bullets/titles\n".
" --nocolor Don't print output in color\n".
"\n"; "\n";
exit; exit;
} }
# CONFIGURATION ITEMS # CONFIGURATION ITEMS
my $revision = "1"; my ($good,$bad,$info);
my $good = "[\e[00;32mOK\e[00m]"; if ($opt{nocolor} == 0) {
my $bad = "[\e[00;31m!!\e[00m]"; $good = "[\e[00;32mOK\e[00m]";
my $info = "[\e[00;34m--\e[00m]"; $bad = "[\e[00;31m!!\e[00m]";
$info = "[\e[00;34m--\e[00m]";
} else {
$good = "[OK]";
$bad = "[!!]";
$info = "[--]";
}
if ($opt{explainonly} == 1) { if ($opt{explainonly} == 1) {
$opt{nogood} = 1; $opt{nogood} = 1;
@ -88,7 +97,7 @@ sub titleprint {
my $exptext; my $exptext;
sub explainprint { sub explainprint {
if ($opt{noexplain} == 1) { return 0; } if ($opt{withexplain} == 0) { return 0; }
my $text = shift; my $text = shift;
if ($opt{explainonly} == 0) { if ($opt{explainonly} == 0) {
print "\n".wrap("","",$text)."\n\n"; print "\n".wrap("","",$text)."\n\n";
@ -615,7 +624,8 @@ sub performance_options {
# BEGIN 'MAIN' # BEGIN 'MAIN'
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
print " MySQL High-Performance Tuner - Major Hayden <major.hayden\@rackspace.com>\n". print " MySQL High-Performance Tuner - Major Hayden <major.hayden\@rackspace.com>\n".
" Bug reports, feature requests, downloads at mysqltuner.com\n"; " Bug reports, feature requests, downloads at mysqltuner.com\n".
" Run with '--help' for additional options and output filtering\n";
mysql_install_ok; # Check to see if MySQL is installed mysql_install_ok; # Check to see if MySQL is installed
os_setup; # Set up some OS variables os_setup; # Set up some OS variables
setup_mysql_login; # Gotta login first setup_mysql_login; # Gotta login first