--version returned exit status 1

This commit is contained in:
frank-cizmich
2016-04-18 12:29:43 -03:00
parent faa8651718
commit f8cdf05988
26 changed files with 546 additions and 93 deletions

View File

@@ -67,6 +67,7 @@ sub new {
'default' => 1,
'cumulative' => 1,
'negatable' => 1,
'repeatable' => 1, # means it can be specified more than once
);
my $self = {
@@ -257,6 +258,7 @@ sub _pod_to_specs {
desc => $para
. (defined $attribs{default} ? " (default $attribs{default})" : ''),
group => ($attribs{'group'} ? $attribs{'group'} : 'default'),
attributes => \%attribs
};
}
while ( $para = <$fh> ) {
@@ -310,6 +312,7 @@ sub _parse_specs {
$opt->{is_negatable} = $opt->{spec} =~ m/!/ ? 1 : 0;
$opt->{is_cumulative} = $opt->{spec} =~ m/\+/ ? 1 : 0;
$opt->{is_repeatable} = $opt->{attributes}->{repeatable} ? 1 : 0;
$opt->{is_required} = $opt->{desc} =~ m/required/ ? 1 : 0;
$opt->{group} ||= 'default';
@@ -453,11 +456,21 @@ sub _set_option {
return;
}
else {
$opt->{value} = $val;
if ($opt->{is_repeatable}) {
push @{$opt->{value}} , $val;
}
else {
$opt->{value} = $val;
}
}
}
else {
$opt->{value} = $val;
if ($opt->{is_repeatable}) {
push @{$opt->{value}} , $val;
}
else {
$opt->{value} = $val;
}
}
$opt->{got} = 1;
PTDEBUG && _d('Got option', $long, '=', $val);
@@ -509,11 +522,12 @@ sub get_opts {
if ( exists $self->{opts}->{version} && $self->{opts}->{version}->{got} ) {
if ( $self->{version} ) {
print $self->{version}, "\n";
exit 0;
}
else {
print "Error parsing version. See the VERSION section of the tool's documentation.\n";
exit 1;
}
exit 1;
}
if ( @ARGV && $self->{strict} ) {
@@ -912,9 +926,9 @@ sub _read_config_file {
next LINE;
}
if ( $parse
&& !$self->has('version-check')
&& $line =~ /version-check/
if ( $parse
&& !$self->has('version-check')
&& $line =~ /version-check/
) {
next LINE;
}