--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

@@ -872,6 +872,7 @@ sub new {
'default' => 1,
'cumulative' => 1,
'negatable' => 1,
'repeatable' => 1, # means it can be specified more than once
);
my $self = {
@@ -1062,6 +1063,7 @@ sub _pod_to_specs {
desc => $para
. (defined $attribs{default} ? " (default $attribs{default})" : ''),
group => ($attribs{'group'} ? $attribs{'group'} : 'default'),
attributes => \%attribs
};
}
while ( $para = <$fh> ) {
@@ -1115,6 +1117,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';
@@ -1258,11 +1261,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);
@@ -1314,11 +1327,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} ) {
@@ -1716,6 +1730,14 @@ sub _read_config_file {
$parse = 0;
next LINE;
}
if ( $parse
&& !$self->has('version-check')
&& $line =~ /version-check/
) {
next LINE;
}
if ( $parse
&& (my($opt, $arg) = $line =~ m/^\s*([^=\s]+?)(?:\s*=\s*(.*?)\s*)?$/)
) {