File Coverage

blib/lib/Bash/Completion/Plugins/App/Cmd.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 27 27 100.0


line stmt bran cond sub pod time code
1             ## no critic (RequireUseStrict)
2             package Bash::Completion::Plugins::App::Cmd;
3             $Bash::Completion::Plugins::App::Cmd::VERSION = '0.02';
4             ## use critic (RequireUseStrict)
5 1     1   2144 use strict;
  1         2  
  1         23  
6 1     1   5 use warnings;
  1         1  
  1         26  
7 1     1   5 use parent 'Bash::Completion::Plugin';
  1         2  
  1         7  
8              
9 1     1   1751 use Bash::Completion::Utils qw(prefix_match);
  1         2442  
  1         64  
10 1     1   731 use Class::Load qw(load_class);
  1         20356  
  1         151  
11              
12             sub complete {
13 4     4 1 2994 my ( $self, $r ) = @_;
14              
15 4         15 my $class = $self->command_class;
16 4         19 load_class($class);
17              
18 4         29661 my @names = $class->command_names;
19              
20 4         11035 $r->candidates(prefix_match($r->word, @names));
21             }
22              
23             1;
24              
25             =pod
26              
27             =encoding UTF-8
28              
29             =head1 NAME
30              
31             Bash::Completion::Plugins::App::Cmd - A Bash::Completion plugin for writing App::Cmd plugins
32              
33             =head1 VERSION
34              
35             version 0.02
36              
37             =head1 SYNOPSIS
38              
39             use parent 'Bash::Completion::Plugins::App::Cmd';
40              
41             # fill in everything you normally would for Bash::Completion,
42             # except for complete
43              
44             sub command_class { 'My::Cmd' } # mandatory
45              
46             =head1 DESCRIPTION
47              
48             This is a L plugin that assists in writing other
49             L plugins for programs that use L. Everything
50             is done similar to writing a normal L plugin, except you
51             need to define the L method rather than the
52             L<'Bash::Completion::Plugin'/complete> method. L is
53             the name of the class that you use C from.
54              
55             =head1 METHODS
56              
57             =head2 complete
58              
59             Populates the L request with commands from the
60             given L class.
61              
62             =head2 command_class
63              
64             Returns the name of the class that this plugin will extract command
65             names from. This method must be implemented by subclasses.
66              
67             =head1 SEE ALSO
68              
69             L, L
70              
71             =head1 AUTHOR
72              
73             Rob Hoelz
74              
75             =head1 COPYRIGHT AND LICENSE
76              
77             This software is copyright (c) 2012 by Rob Hoelz.
78              
79             This is free software; you can redistribute it and/or modify it under
80             the same terms as the Perl 5 programming language system itself.
81              
82             =cut
83              
84             __END__