Bash/Completion/Plugins/BashComplete.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran 66.6% 4 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 93.8% 46 / 49 CC 5 SCAR 11.1
CC
5
Cov
92%
complete
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« Bash/Completion/Utils.pm ↑ Summary Bash/Completion.pm »
1 package Bash::Completion::Plugins::BashComplete;
2 {
3 2 $Bash::Completion::Plugins::BashComplete::VERSION = '0.008';
4 }
5  
6 # ABSTRACT: Plugin for bash-complete
7  
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use parent 'Bash::Completion::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 use Bash::Completion::Utils
12 2 ▶ qw( command_in_path match_perl_modules prefix_match );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 1 ▶sub should_activate {
Subroutine should_activate: called CC=1 SCAR=0.0
Pod documented
16 1 my @commands = ('bash-complete');
17 1 return [grep { command_in_path($_) } @commands];
18 }
19  
20  
21  
22 2 my @commands = qw{ setup complete };
23 2 my @options = ('--help', '-h');
24  
25 3 ▶sub complete {
Subroutine complete: called CC=5 SCAR=16.3
Pod documented
26 3 my ($class, $req) = @_;
27 3 my $word = $req->word;
28 3 my @args = $req->args;
29 3 my $count = $req->count;
30  
31 3 my @c;
32 3 ▶ if (index($word, '-') == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if (index($word, '-') == 0) { } 0 3 3
elsif ($count >= 2 and $args[1] eq 'complete') { } 1 2 3
elsif ($count <= 2) { } 2 0 2
33 0 @c = prefix_match($word, @options);
34 }
35 ▶ elsif ($count >= 2 && $args[1] eq 'complete') {
Condition100%3/3
$count >= 2 and $args[1] eq "complete"
!ll&&!rl&&r
111
MC/DC100%2/2
$count >= 2 and $args[1] eq "complete"
$count >= 2 $args[1] eq "complete"
Truth table100%3/3
A and B
A= $count >= 2B= $args[1] eq "complete"
ABresult
0X0
100
111
36 1 @c = match_perl_modules("Bash::Completion::Plugins::$word");
37 }
38 elsif ($count <= 2) {
39 2 @c = prefix_match($word, @commands, @options);
40 }
41  
42 3 $req->candidates(@c);
43 }
44  
45 2 1;
46  
47  
48  
49 =pod
50  
51 =head1 NAME
52  
53 Bash::Completion::Plugins::BashComplete - Plugin for bash-complete
54  
55 =head1 VERSION
56  
57 version 0.008
58  
59 =head1 SYNOPSIS
60  
61 ## not to be used directly
62  
63 =head1 DESCRIPTION
64  
65 A plugin for the C<base-complete> command. Completes options and
66 sub-commands.
67  
68 For the C<complete> sub-command, it completes with the plugin names.
69  
70 =head1 METHODS
71  
72 =head2 should_activate
73  
74 Makes sure we only activate this plugin if we can find C<bash-complete>
75 in our PATH.
76  
77 =head2 complete
78  
79 Completion logic for C<bash-complete>
80  
81 =head1 AUTHOR
82  
83 Pedro Melo <melo@cpan.org>
84  
85 =head1 COPYRIGHT AND LICENSE
86  
87 This software is Copyright (c) 2011 by Pedro Melo.
88  
89 This is free software, licensed under:
90  
91 The Artistic License 2.0 (GPL Compatible)
92  
93 =cut
94  
95  
96 __END__
« Bash/Completion/Utils.pm ↑ Summary Bash/Completion.pm »