| 1 | package Complete::Program; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | our $DATE = '2016-02-06'; # DATE | |||||||||||||||||||||||||||
| 4 | 2 | our $VERSION = '0.39'; # VERSION | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Complete::Common qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | require Exporter; | |||||||||||||||||||||||||||
| 13 | 2 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 14 | 2 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||
| 15 | complete_program | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | our %SPEC; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | $SPEC{':package'} = { | |||||||||||||||||||||||||||
| 21 | v => 1.1, | ||||||||||||||||||||||||||||
| 22 | summary => 'Completion routines related to program names', | ||||||||||||||||||||||||||||
| 23 | }; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | $SPEC{complete_program} = { | ||||||||||||||||||||||||||||
| 26 | 2 | v => 1.1, | |||||||||||||||||||||||||||
| 27 | summary => 'Complete program name found in PATH', | ||||||||||||||||||||||||||||
| 28 | description => <<'_', | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | Windows is supported, on Windows PATH will be split using /;/ instead of /:/. | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | _ | ||||||||||||||||||||||||||||
| 33 | args => { | ||||||||||||||||||||||||||||
| 34 | word => { schema=>[str=>{default=>''}], pos=>0, req=>1 }, | ||||||||||||||||||||||||||||
| 35 | }, | ||||||||||||||||||||||||||||
| 36 | result_naked => 1, | ||||||||||||||||||||||||||||
| 37 | result => { | ||||||||||||||||||||||||||||
| 38 | schema => 'array', | ||||||||||||||||||||||||||||
| 39 | }, | ||||||||||||||||||||||||||||
| 40 | }; | ||||||||||||||||||||||||||||
| 41 | 6 | ▶ | sub complete_program { | ||||||||||||||||||||||||||
|
Subroutine
complete_program: called CC=8 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | 6 | require Complete::Util; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 6 | my %args = @_; | |||||||||||||||||||||||||||
| 45 | 6 | ▶ | my $word = $args{word} // ""; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{"word"} // ""
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table50%1/2
A
A= $args{"word"}
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 6 | ▶ | my @dirs = split(($^O =~ /Win32/ ? qr/;/ : qr/:/), $ENV{PATH}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 6 | my @all_progs; | |||||||||||||||||||||||||||
| 49 | 6 | for my $dir (@dirs) { | |||||||||||||||||||||||||||
| 50 | 12 | ▶ | opendir my($dh), $dir or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 12 | for (readdir($dh)) { | |||||||||||||||||||||||||||
| 52 | 42 | ▶ | push @all_progs, $_ if !(-d "$dir/$_") && (-x _); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not -d "$dir/$_" and -x _
MC/DC50%1/2
not -d "$dir/$_" and -x _
not -d "$dir/$_"
-x _
Truth table66%2/3
not(A) and B
A= not -d "$dir/$_"B= -x _
| |||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | Complete::Util::complete_array_elem( | ||||||||||||||||||||||||||||
| 57 | 6 | word => $word, array => \@all_progs, | |||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 2 | 1; | |||||||||||||||||||||||||||
| 62 | # ABSTRACT: Completion routines related to program names | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||