| 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
| |||||||||||||||||||||
| 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"
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"
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||