| 1 | package Pod::Perldoc::GetOptsOO; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | $VERSION = '3.28'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | BEGIN { # Make a DEBUG constant ASAP | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 8 | *DEBUG = defined( &Pod::Perldoc::DEBUG ) | ||||||||||||||||||||||||||||
| 9 | ? \&Pod::Perldoc::DEBUG | ||||||||||||||||||||||||||||
| 10 | 3 | ▶ | : sub(){10}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | sub getopts { | ||||||||||||||||||||||||||
|
Subroutine
getopts: called CC=18 SCAR=50.9
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 2 | my($target, $args, $truth) = @_; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | $args ||= \@ARGV; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args ||= \@ARGV
MC/DC0%0/1
$args ||= \@ARGV
$args
Truth table50%1/2
A
A= $args
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | $target->aside( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | "Starting switch processing. Scanning arguments [@$args]\n" | ||||||||||||||||||||||||||||
| 21 | ) if $target->can('aside'); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | return unless @$args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 2 | ▶ | $truth = 1 unless @_ > 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 2 | DEBUG > 3 and print " Truth is $truth\n"; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | my $error_count = 0; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 2 | ▶ | while( @$args and ($_ = $args->[0]) =~ m/^-(.)(.*)/s ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$args and ($_ = $args->[0]) =~ /^-(.)(.*)/s
MC/DC0%0/2
@$args and ($_ = $args->[0]) =~ /^-(.)(.*)/s
@$args
($_ = $args->[0]) =~ /^-(.)(.*)/s
Truth table33%1/3
A and B
A= @$argsB= ($_ = $args->[0]) =~ /^-(.)(.*)/s
| |||||||||||||||||||||||||||||
| 33 | 0 | my($first,$rest) = ($1,$2); | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ($_ eq '--') { # early exit if "--" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | shift @$args; | |||||||||||||||||||||||||||
| 36 | 0 | last; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ($first eq '-' and $rest) { # GNU style long param names | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$first eq "-" and $rest
MC/DC0%0/2
$first eq "-" and $rest
$first eq "-"
$rest
Truth table0%0/3
A and B
A= $first eq "-"B= $rest
| |||||||||||||||||||||||||||||
| 39 | 0 | ($first, $rest) = split '=', $rest, 2; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 0 | my $method = "opt_${first}_with"; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | if( $target->can($method) ) { # it's argumental | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if($rest eq '') { # like -f bar | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | shift @$args; | |||||||||||||||||||||||||||
| 45 | 0 | ▶ | $target->warn( "Option $first needs a following argument!\n" ) unless @$args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 0 | $rest = shift @$args; | |||||||||||||||||||||||||||
| 47 | } else { # like -fbar (== -f bar) | ||||||||||||||||||||||||||||
| 48 | 0 | shift @$args; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | DEBUG > 3 and print " $method => $rest\n"; | |||||||||||||||||||||||||||
| 52 | 0 | $target->$method( $rest ); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # Otherwise, it's not argumental... | ||||||||||||||||||||||||||||
| 55 | } else { | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if( $target->can( $method = "opt_$first" ) ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 58 | 0 | DEBUG > 3 and print " $method is true ($truth)\n"; | |||||||||||||||||||||||||||
| 59 | 0 | $target->$method( $truth ); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | # Otherwise it's an unknown option... | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | } elsif( $target->can('handle_unknown_option') ) { | ||||||||||||||||||||||||||||
| 64 | 0 | DEBUG > 3 | |||||||||||||||||||||||||||
| 65 | and print " calling handle_unknown_option('$first')\n"; | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $error_count += ( | ||||||||||||||||||||||||||
|
Condition0%0/2
$target->handle_unknown_option($first) || 0
MC/DC0%0/1
$target->handle_unknown_option($first) || 0
$target->handle_unknown_option($first)
Truth table0%0/2
A
A= $target->handle_unknown_option($first)
| |||||||||||||||||||||||||||||
| 68 | $target->handle_unknown_option( $first ) || 0 | ||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | } else { | ||||||||||||||||||||||||||||
| 72 | 0 | ++$error_count; | |||||||||||||||||||||||||||
| 73 | 0 | $target->warn( "Unknown option: $first\n" ); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if($rest eq '') { # like -f | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | shift @$args | |||||||||||||||||||||||||||
| 78 | } else { # like -fbar (== -f -bar ) | ||||||||||||||||||||||||||||
| 79 | 0 | DEBUG > 2 and print " Setting args->[0] to \"-$rest\"\n"; | |||||||||||||||||||||||||||
| 80 | 0 | $args->[0] = "-$rest"; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | $target->aside( | ||||||||||||||||||||||||||||
| 87 | 2 | ▶ | "Ending switch processing. Args are [@$args] with $error_count errors.\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | ) if $target->can('aside'); | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 2 | $error_count == 0; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 3 | 1; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | __END__ | ||||||||||||||||||||||||||||