| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
## no critic (RequireUseStrict) |
|
2
|
|
|
|
|
|
|
package Bash::Completion::Plugins::pinto; |
|
3
|
|
|
|
|
|
|
# git description: v0.002-1-g02cd2bc |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN { |
|
6
|
1
|
|
|
1
|
|
36328
|
$Bash::Completion::Plugins::pinto::AUTHORITY = 'cpan:SCHWIGON'; |
|
7
|
|
|
|
|
|
|
} |
|
8
|
|
|
|
|
|
|
{ |
|
9
|
|
|
|
|
|
|
$Bash::Completion::Plugins::pinto::VERSION = '0.003'; |
|
10
|
|
|
|
|
|
|
} |
|
11
|
|
|
|
|
|
|
# ABSTRACT: Bash completion for pinto |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
## use critic (RequireUseStrict) |
|
14
|
1
|
|
|
1
|
|
9
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
15
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
16
|
1
|
|
|
1
|
|
10
|
use feature 'switch'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
131
|
|
|
17
|
1
|
|
|
1
|
|
900
|
use parent 'Bash::Completion::Plugin'; |
|
|
1
|
|
|
|
|
352
|
|
|
|
1
|
|
|
|
|
5
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
3485
|
use Bash::Completion::Utils qw(command_in_path); |
|
|
1
|
|
|
|
|
4574
|
|
|
|
1
|
|
|
|
|
363
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my @pinto_commands = qw/commands help add copy |
|
22
|
|
|
|
|
|
|
delete edit index init |
|
23
|
|
|
|
|
|
|
install list manual merge |
|
24
|
|
|
|
|
|
|
new nop pin props pull |
|
25
|
|
|
|
|
|
|
stacks statistics unpin |
|
26
|
|
|
|
|
|
|
verify version |
|
27
|
|
|
|
|
|
|
/; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my @pinto_options = qw/-h --help |
|
30
|
|
|
|
|
|
|
-r --root |
|
31
|
|
|
|
|
|
|
-q --quiet |
|
32
|
|
|
|
|
|
|
-v --verbose |
|
33
|
|
|
|
|
|
|
--nocolor |
|
34
|
|
|
|
|
|
|
/; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub should_activate { |
|
37
|
0
|
|
|
0
|
1
|
0
|
return [ grep { command_in_path($_) } qw/pinto/ ]; |
|
|
0
|
|
|
|
|
0
|
|
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _extract_stack { |
|
41
|
0
|
|
|
0
|
|
0
|
my ( $stack ) = @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#$stack =~ s/\@.*//; |
|
44
|
0
|
|
|
|
|
0
|
return $stack; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _get_stacks { |
|
48
|
0
|
|
|
0
|
|
0
|
my @stacks = split /\n/, qx(pinto stacks); |
|
49
|
0
|
|
|
|
|
0
|
my ( $current_stack ) = grep { /^\*\s*/ } @stacks; |
|
|
0
|
|
|
|
|
0
|
|
|
50
|
0
|
|
|
|
|
0
|
( $current_stack ) = $current_stack =~ /^\*\s*(\S+)/; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
$current_stack = _extract_stack($current_stack); |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
|
1121
|
return ( $current_stack, map { /^\*?\s*(?\S+)/; $+{'name'} } @stacks ); |
|
|
1
|
|
|
|
|
625
|
|
|
|
1
|
|
|
|
|
1407
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub complete { |
|
58
|
12
|
|
|
12
|
1
|
28574
|
my ( $self, $r ) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
12
|
|
|
|
|
41
|
my $word = $r->word; |
|
61
|
|
|
|
|
|
|
|
|
62
|
12
|
50
|
|
|
|
87
|
if ($word =~ /^-/) { |
|
63
|
0
|
|
|
|
|
0
|
$r->candidates(grep { /^\Q$word\E/ } @pinto_options); |
|
|
0
|
|
|
|
|
0
|
|
|
64
|
|
|
|
|
|
|
} else { |
|
65
|
12
|
|
|
|
|
35
|
my @args = $r->args; |
|
66
|
|
|
|
|
|
|
|
|
67
|
12
|
|
|
|
|
98
|
my @orig_args = @args; |
|
68
|
|
|
|
|
|
|
|
|
69
|
12
|
|
|
|
|
18
|
shift @args; # get rid of 'pinto' |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# get rid of (-rFOO|-r FOO|--root FOO|--root=FOO) |
|
72
|
12
|
100
|
100
|
|
|
134
|
if ($args[0] and $args[0] =~ qr/^(?:-r|--root)$/) { |
|
73
|
4
|
50
|
|
|
|
31
|
if ($args[0] =~ qr/^(?:--root=)$/) { |
|
|
|
50
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
shift @args; |
|
75
|
|
|
|
|
|
|
} elsif ($args[1]) { |
|
76
|
4
|
|
|
|
|
8
|
shift @args; |
|
77
|
4
|
|
|
|
|
8
|
shift @args; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
12
|
|
100
|
|
|
86
|
shift @args until @args == 0 || $args[0] !~ /^-/; |
|
82
|
|
|
|
|
|
|
|
|
83
|
12
|
|
100
|
|
|
43
|
my $command = $args[0] // ''; |
|
84
|
|
|
|
|
|
|
|
|
85
|
12
|
|
|
|
|
17
|
my @options = (); |
|
86
|
12
|
|
|
|
|
20
|
given($command) { |
|
87
|
12
|
|
|
|
|
35
|
when ("add") { @options = qw(--author --dryrun --norecurse --pin --stack); } |
|
|
0
|
|
|
|
|
0
|
|
|
88
|
12
|
|
|
|
|
19
|
when ("copy") { @options = qw(--description --dryrun); } |
|
|
0
|
|
|
|
|
0
|
|
|
89
|
12
|
|
|
|
|
22
|
when ("edit") { @options = qw(--default --dryrun --properties -P); } |
|
|
0
|
|
|
|
|
0
|
|
|
90
|
12
|
|
|
|
|
18
|
when ("init") { @options = qw(--source); } |
|
|
0
|
|
|
|
|
0
|
|
|
91
|
12
|
|
|
|
|
19
|
when ("install") { @options = qw(--cpanm-exe --cpanm |
|
|
0
|
|
|
|
|
0
|
|
|
92
|
|
|
|
|
|
|
--cpanm-options -o |
|
93
|
|
|
|
|
|
|
-l --local-lib --local-lib-contained |
|
94
|
|
|
|
|
|
|
--pull |
|
95
|
|
|
|
|
|
|
--stack |
|
96
|
|
|
|
|
|
|
); } |
|
97
|
12
|
|
|
|
|
14
|
when ("list") { @options = qw(--author -A |
|
|
0
|
|
|
|
|
0
|
|
|
98
|
|
|
|
|
|
|
--distributions -D |
|
99
|
|
|
|
|
|
|
--format |
|
100
|
|
|
|
|
|
|
--packages -P |
|
101
|
|
|
|
|
|
|
--pinned |
|
102
|
|
|
|
|
|
|
--stack -s |
|
103
|
|
|
|
|
|
|
); } |
|
104
|
12
|
|
|
|
|
17
|
when ("merge") { @options = qw(--dryrun); } |
|
|
0
|
|
|
|
|
0
|
|
|
105
|
12
|
|
|
|
|
16
|
when ("new") { @options = qw(--dryrun --description); } |
|
|
0
|
|
|
|
|
0
|
|
|
106
|
12
|
|
|
|
|
13
|
when ("nop") { @options = qw(--sleep); } |
|
|
0
|
|
|
|
|
0
|
|
|
107
|
12
|
|
|
|
|
15
|
when ("pin") { @options = qw(--dryrun --stack); } |
|
|
0
|
|
|
|
|
0
|
|
|
108
|
12
|
|
|
|
|
15
|
when ("props") { @options = qw(--format); } |
|
|
0
|
|
|
|
|
0
|
|
|
109
|
12
|
|
|
|
|
14
|
when ("pull") { @options = qw(--dryrun --norecurse --stack); } |
|
|
0
|
|
|
|
|
0
|
|
|
110
|
12
|
|
|
|
|
17
|
when ("stacks") { @options = qw(--format); } |
|
|
0
|
|
|
|
|
0
|
|
|
111
|
12
|
|
|
|
|
13
|
when ("unpin") { @options = qw(--dryrun --stack); } |
|
|
0
|
|
|
|
|
0
|
|
|
112
|
12
|
|
|
|
|
38
|
default { }; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
12
|
|
|
|
|
17
|
given($command) { |
|
116
|
12
|
|
|
|
|
22
|
when($command eq $word) { |
|
117
|
12
|
|
|
|
|
21
|
$r->candidates(grep { /^\Q$word\E/ } |
|
|
372
|
|
|
|
|
1213
|
|
|
118
|
|
|
|
|
|
|
( @pinto_commands, @pinto_options )); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
##_get_stacks() is quite slow for my demanding taste (due to slow pinto startup time) |
|
121
|
0
|
|
|
|
|
|
when(qr/^(?:copy|delete|index|list|merge|pin|unpin)$/) { |
|
122
|
0
|
|
|
|
|
|
my ( $current_stack, @stacks ) = _get_stacks(); |
|
123
|
0
|
|
|
|
|
|
$r->candidates(grep { /^\Q$word\E/ } ( @options, @stacks )); |
|
|
0
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
|
125
|
0
|
|
|
|
|
|
when(qr/^(?:manual|help)$/) { |
|
126
|
0
|
|
|
|
|
|
$r->candidates(grep { /^\Q$word\E/ } |
|
|
0
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
( @pinto_commands )); |
|
128
|
|
|
|
|
|
|
} |
|
129
|
0
|
|
|
|
|
|
default { |
|
130
|
|
|
|
|
|
|
# all other commands (including unrecognized ones) get |
|
131
|
|
|
|
|
|
|
# no completions |
|
132
|
0
|
|
|
|
|
|
$r->candidates(grep { /^\Q$word\E/ } ( @options )); |
|
|
0
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=pod |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=encoding utf-8 |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 NAME |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Bash::Completion::Plugins::pinto - Bash completion for pinto |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L support for L. Completes pinto |
|
153
|
|
|
|
|
|
|
commands and options. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L, L, L |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 ACKNOWLEDGMENTS |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Derived from L by Rob Hoelz. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=begin comment |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=over |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item should_activate |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item complete |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=back |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=end comment |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 AUTHOR |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Steffen Schwigon |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Steffen Schwigon. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
184
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
__END__ |