Fix the usage for non-boolean options, always print the

description. This fixes the output of 'make_filter --help'.
This commit is contained in:
Francois Gouget 2004-10-25 21:50:36 +00:00 committed by Alexandre Julliard
parent d9c97f37d9
commit 1d691d5d70
2 changed files with 15 additions and 14 deletions

View File

@ -39,7 +39,7 @@ my %options_long = (
"make" => { default => "make",
parser => \&parse_value,
description => "use which make" },
description => "Specifies the make command" },
"pedantic" => { default => 0, description => "be pedantic" },
);

View File

@ -331,20 +331,20 @@ sub show_help {
for my $name (sort(keys(%$options_long))) {
my $option = $$options_long{$name};
my $description = $$option{description};
my $default = $$option{default};
my $parser = $$option{parser};
my $current = ${$self->{$$option{key}}};
my $value = $current;
my $command;
if(ref($value) ne "HASH") {
if(!defined $parser) {
if($value) {
$command = "--no-$name";
} else {
$command = "--$name";
}
} else {
if($value->{active}) {
if(ref($value) eq "HASH" && $value->{active}) {
$command = "--[no-]$name\[=<value>]";
} else {
$command = "--$name\[=<value>]";
@ -352,23 +352,24 @@ sub show_help {
}
$output->write($command);
for (0..(($maxname - length($name) + 17) - (length($command) - length($name) + 1))) { $output->write(" "); }
if(ref($value) ne "HASH") {
$output->write(" " x (($maxname - length($name) + 17) - (length($command) - length($name) + 1)));
if(!defined $parser) {
if($value) {
$output->write("Disable ");
} else {
$output->write("Enable ");
}
} else {
if($value->{active}) {
$output->write("(Disable) ");
} else {
$output->write("Enable ");
}
}
if($default == $current) {
$output->write("$description\n");
if(ref($value) eq "HASH")
{
if ($value->{active}) {
$output->write("(Disable) ");
} else {
$output->write("Enable ");
}
}
}
$output->write("$description\n");
}
}