line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Complete::Program; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2015-11-29'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.38'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
65541
|
use 5.010001; |
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
872
|
use Complete::Common qw(:all); |
|
1
|
|
|
|
|
499
|
|
|
1
|
|
|
|
|
1683
|
|
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
|
|
|
|
|
|
|
require Complete::Util; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my %args = @_; |
48
|
|
|
|
|
|
|
my $word = $args{word} // ""; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my @dirs = split(($^O =~ /Win32/ ? qr/;/ : qr/:/), $ENV{PATH}); |
51
|
|
|
|
|
|
|
my @all_progs; |
52
|
|
|
|
|
|
|
for my $dir (@dirs) { |
53
|
|
|
|
|
|
|
opendir my($dh), $dir or next; |
54
|
|
|
|
|
|
|
for (readdir($dh)) { |
55
|
|
|
|
|
|
|
push @all_progs, $_ if !(-d "$dir/$_") && (-x _); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Complete::Util::complete_array_elem( |
60
|
|
|
|
|
|
|
word => $word, array => \@all_progs, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
# ABSTRACT: Completion routines related to program names |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |