line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## no critic (RequireUseStrict) |
2
|
|
|
|
|
|
|
package Bash::Completion::Plugins::pinto; |
3
|
|
|
|
|
|
|
BEGIN { |
4
|
1
|
|
|
1
|
|
27676
|
$Bash::Completion::Plugins::pinto::AUTHORITY = 'cpan:SCHWIGON'; |
5
|
|
|
|
|
|
|
} |
6
|
|
|
|
|
|
|
# ABSTRACT: Bash completion for pinto |
7
|
|
|
|
|
|
|
$Bash::Completion::Plugins::pinto::VERSION = '0.004'; |
8
|
|
|
|
|
|
|
## use critic (RequireUseStrict) |
9
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
11
|
1
|
|
|
1
|
|
7
|
use feature 'switch'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
140
|
|
12
|
1
|
|
|
1
|
|
910
|
use parent 'Bash::Completion::Plugin'; |
|
1
|
|
|
|
|
347
|
|
|
1
|
|
|
|
|
6
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
2199
|
use Bash::Completion::Utils qw(command_in_path); |
|
1
|
|
|
|
|
3010
|
|
|
1
|
|
|
|
|
372
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @pinto_commands = qw/commands help add copy |
17
|
|
|
|
|
|
|
delete edit index init |
18
|
|
|
|
|
|
|
install list manual merge |
19
|
|
|
|
|
|
|
new nop pin props pull |
20
|
|
|
|
|
|
|
stacks statistics unpin |
21
|
|
|
|
|
|
|
verify version |
22
|
|
|
|
|
|
|
/; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my @pinto_options = qw/-h --help |
25
|
|
|
|
|
|
|
-r --root |
26
|
|
|
|
|
|
|
-q --quiet |
27
|
|
|
|
|
|
|
-v --verbose |
28
|
|
|
|
|
|
|
--nocolor |
29
|
|
|
|
|
|
|
/; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub should_activate { |
32
|
0
|
|
|
0
|
1
|
0
|
return [ grep { command_in_path($_) } qw/pinto/ ]; |
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _extract_stack { |
36
|
0
|
|
|
0
|
|
0
|
my ( $stack ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#$stack =~ s/\@.*//; |
39
|
0
|
|
|
|
|
0
|
return $stack; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _get_stacks { |
43
|
0
|
|
|
0
|
|
0
|
my @stacks = split /\n/, qx(pinto stacks); |
44
|
0
|
|
|
|
|
0
|
my ( $current_stack ) = grep { /^\*\s*/ } @stacks; |
|
0
|
|
|
|
|
0
|
|
45
|
0
|
|
|
|
|
0
|
( $current_stack ) = $current_stack =~ /^\*\s*(\S+)/; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
$current_stack = _extract_stack($current_stack); |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
1
|
|
1045
|
return ( $current_stack, map { /^\*?\s*(?\S+)/; $+{'name'} } @stacks ); |
|
1
|
|
|
|
|
550
|
|
|
1
|
|
|
|
|
1189
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub complete { |
53
|
12
|
|
|
12
|
1
|
32939
|
my ( $self, $r ) = @_; |
54
|
|
|
|
|
|
|
|
55
|
12
|
|
|
|
|
49
|
my $word = $r->word; |
56
|
|
|
|
|
|
|
|
57
|
12
|
50
|
|
|
|
92
|
if ($word =~ /^-/) { |
58
|
0
|
|
|
|
|
0
|
$r->candidates(grep { /^\Q$word\E/ } @pinto_options); |
|
0
|
|
|
|
|
0
|
|
59
|
|
|
|
|
|
|
} else { |
60
|
12
|
|
|
|
|
46
|
my @args = $r->args; |
61
|
|
|
|
|
|
|
|
62
|
12
|
|
|
|
|
108
|
my @orig_args = @args; |
63
|
|
|
|
|
|
|
|
64
|
12
|
|
|
|
|
24
|
shift @args; # get rid of 'pinto' |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# get rid of (-rFOO|-r FOO|--root FOO|--root=FOO) |
67
|
12
|
100
|
100
|
|
|
149
|
if ($args[0] and $args[0] =~ qr/^(?:-r|--root)$/) { |
68
|
4
|
50
|
|
|
|
32
|
if ($args[0] =~ qr/^(?:--root=)$/) { |
|
|
50
|
|
|
|
|
|
69
|
0
|
|
|
|
|
0
|
shift @args; |
70
|
|
|
|
|
|
|
} elsif ($args[1]) { |
71
|
4
|
|
|
|
|
7
|
shift @args; |
72
|
4
|
|
|
|
|
8
|
shift @args; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
12
|
|
100
|
|
|
112
|
shift @args until @args == 0 || $args[0] !~ /^-/; |
77
|
|
|
|
|
|
|
|
78
|
12
|
|
100
|
|
|
44
|
my $command = $args[0] // ''; |
79
|
|
|
|
|
|
|
|
80
|
12
|
|
|
|
|
26
|
my @options = (); |
81
|
12
|
|
|
|
|
30
|
for ($command) { |
82
|
12
|
50
|
|
|
|
39
|
/^add$/ and do { @options = qw(--author --dryrun --norecurse --pin --stack); last }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
83
|
12
|
50
|
|
|
|
34
|
/^(?:copy|new)$/ and do { @options = qw(--description --dryrun); last }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
84
|
12
|
50
|
|
|
|
35
|
/^edit$/ and do { @options = qw(--default --dryrun --properties -P); last }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
85
|
12
|
50
|
|
|
|
30
|
/^init$/ and do { @options = qw(--source); last }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
86
|
12
|
50
|
|
|
|
32
|
/^install$/ and do { @options = qw(--cpanm-exe --cpanm |
|
0
|
|
|
|
|
0
|
|
87
|
|
|
|
|
|
|
--cpanm-options -o |
88
|
|
|
|
|
|
|
-l --local-lib --local-lib-contained |
89
|
|
|
|
|
|
|
--pull |
90
|
|
|
|
|
|
|
--stack |
91
|
0
|
|
|
|
|
0
|
); last }; |
92
|
12
|
50
|
|
|
|
30
|
/^list$/ and do { @options = qw(--author -A |
|
0
|
|
|
|
|
0
|
|
93
|
|
|
|
|
|
|
--distributions -D |
94
|
|
|
|
|
|
|
--format |
95
|
|
|
|
|
|
|
--packages -P |
96
|
|
|
|
|
|
|
--pinned |
97
|
|
|
|
|
|
|
--stack -s |
98
|
0
|
|
|
|
|
0
|
); last }; |
99
|
12
|
50
|
|
|
|
31
|
/^merge$/ and do { @options = qw(--dryrun); last }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
100
|
12
|
50
|
|
|
|
29
|
/^nop$/ and do { @options = qw(--sleep); last }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
101
|
12
|
50
|
|
|
|
34
|
/^(?:un)?pin$/ and do { @options = qw(--dryrun --stack); last }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
102
|
12
|
50
|
|
|
|
28
|
/^(props|stacks)$/ and do { @options = qw(--format); last }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
103
|
12
|
50
|
|
|
|
39
|
/^pull$/ and do { @options = qw(--dryrun --norecurse --stack); last }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
12
|
|
|
|
|
25
|
for ($command) { |
107
|
12
|
50
|
|
|
|
41
|
$_ eq $word and do { |
108
|
12
|
|
|
|
|
29
|
$r->candidates(grep { /^\Q$word\E/ } |
|
372
|
|
|
|
|
1357
|
|
109
|
|
|
|
|
|
|
( @pinto_commands, @pinto_options )); |
110
|
12
|
|
|
|
|
145
|
last; |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
##_get_stacks() is quite slow for my demanding taste (due to slow pinto startup time) |
113
|
0
|
0
|
|
|
|
|
/^(?:copy|delete|index|list|merge|pin|unpin)$/ and do { |
114
|
0
|
|
|
|
|
|
my ( $current_stack, @stacks ) = _get_stacks(); |
115
|
0
|
|
|
|
|
|
$r->candidates(grep { /^\Q$word\E/ } ( @options, @stacks )); |
|
0
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
last; |
117
|
|
|
|
|
|
|
}; |
118
|
0
|
0
|
|
|
|
|
/^(?:manual|help)$/ and do { |
119
|
0
|
|
|
|
|
|
$r->candidates(grep { /^\Q$word\E/ } |
|
0
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
( @pinto_commands )); |
121
|
0
|
|
|
|
|
|
last; |
122
|
|
|
|
|
|
|
}; |
123
|
|
|
|
|
|
|
# all other commands (including unrecognized ones) get |
124
|
|
|
|
|
|
|
# no completions |
125
|
0
|
|
|
|
|
|
$r->candidates(grep { /^\Q$word\E/ } ( @options )); |
|
0
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
__END__ |