line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Complete::Program; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2015-09-17'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.37'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
60500
|
use 5.010001; |
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
695
|
use Complete::Setting; |
|
1
|
|
|
|
|
196
|
|
|
1
|
|
|
|
|
356
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Exporter; |
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
15
|
|
|
|
|
|
|
complete_program |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our %SPEC; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$SPEC{':package'} = { |
21
|
|
|
|
|
|
|
v => 1.1, |
22
|
|
|
|
|
|
|
summary => 'Completion routines related to program names', |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$SPEC{complete_program} = { |
26
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
ci => { schema=>'bool' }, |
36
|
|
|
|
|
|
|
fuzzy => { schema=>['int*', min=>0] }, |
37
|
|
|
|
|
|
|
map_case => { schema=>'bool' }, |
38
|
|
|
|
|
|
|
}, |
39
|
|
|
|
|
|
|
result_naked => 1, |
40
|
|
|
|
|
|
|
result => { |
41
|
|
|
|
|
|
|
schema => 'array', |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
sub complete_program { |
45
|
7
|
|
|
7
|
1
|
8693
|
require Complete::Util; |
46
|
|
|
|
|
|
|
|
47
|
7
|
|
|
|
|
1996
|
my %args = @_; |
48
|
7
|
|
50
|
|
|
18
|
my $word = $args{word} // ""; |
49
|
7
|
|
66
|
|
|
19
|
my $ci = $args{ci} // $Complete::Setting::OPT_CI; |
50
|
7
|
|
33
|
|
|
21
|
my $fuzzy = $args{fuzzy} // $Complete::Setting::OPT_FUZZY; |
51
|
7
|
|
33
|
|
|
17
|
my $map_case = $args{map_case} // $Complete::Setting::OPT_MAP_CASE; |
52
|
|
|
|
|
|
|
|
53
|
7
|
100
|
|
|
|
64
|
my @dirs = split(($^O =~ /Win32/ ? qr/;/ : qr/:/), $ENV{PATH}); |
54
|
7
|
|
|
|
|
14
|
my @all_progs; |
55
|
7
|
|
|
|
|
13
|
for my $dir (@dirs) { |
56
|
14
|
50
|
|
|
|
307
|
opendir my($dh), $dir or next; |
57
|
14
|
|
|
|
|
129
|
for (readdir($dh)) { |
58
|
51
|
100
|
66
|
|
|
902
|
push @all_progs, $_ if !(-d "$dir/$_") && (-x _); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Complete::Util::complete_array_elem( |
63
|
7
|
|
|
|
|
23
|
word => $word, array => \@all_progs, |
64
|
|
|
|
|
|
|
ci=>$ci, fuzzy=>$fuzzy, map_case=>$map_case, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
# ABSTRACT: Completion routines related to program names |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |