blib/lib/Bash/Completion/Plugins/App/Cmd.pm

filter: Statementstmt 100% 22 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 29 / 29 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 ## no critic (RequireUseStrict)
2 package Bash::Completion::Plugins::App::Cmd;
3 2 $Bash::Completion::Plugins::App::Cmd::VERSION = '0.02';
4 ## use critic (RequireUseStrict)
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use parent 'Bash::Completion::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Bash::Completion::Utils qw(prefix_match);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Class::Load qw(load_class);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 ▶sub complete {
Subroutine complete: called CC=1 SCAR=0.0
Pod documented
13 4 my ( $self, $r ) = @_;
14  
15 4 my $class = $self->command_class;
16 4 load_class($class);
17  
18 4 my @names = $class->command_names;
19  
20 4 $r->candidates(prefix_match($r->word, @names));
21 }
22  
23 2 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<Bash::Completion> plugin that assists in writing other
49 L<Bash::Completion> plugins for programs that use L<App::Cmd>. Everything
50 is done similar to writing a normal L<Bash::Completion> plugin, except you
51 need to define the L</command_class> method rather than the
52 L<'Bash::Completion::Plugin'/complete> method. L</command_class> is
53 the name of the class that you use C<use App::Cmd::Setup -app> from.
54  
55 =head1 METHODS
56  
57 =head2 complete
58  
59 Populates the L<Bash::Completion> request with commands from the
60 given L<App::Cmd> 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<App::Cmd>, L<Bash::Completion>
70  
71 =head1 AUTHOR
72  
73 Rob Hoelz <rob@hoelz.ro>
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__
↑ Summary