P5U/Command/Aliases.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 50 CC 3 SCAR 14.6
CC
3
Cov
0%
execute
12.0
BEGIN
2.0
description
2.0
CRAP 4.3
1 package P5U::Command::Aliases;
2  
3 use 5.010;
4 use strict;
5 use utf8;
6 use P5U-command;
7  
8 BEGIN {
9 $P5U::Command::Aliases::AUTHORITY = 'cpan:TOBYINK';
10 $P5U::Command::Aliases::VERSION = '0.100';
11 };
12  
13 use constant {
14 abstract => q[show aliases for p5u's commands],
15 usage_desc => q[%c aliases],
16 };
17  
18 sub description
19 {
20 <<'DESCRIPTION'
21 Most p5u commands can be invoked with shorter aliases.
22  
23 p5u version Mouse
24 p5u v Mouse # same thing
25  
26 The aliases command (which, ironically, has no shorter alias) shows existing
27 aliases.
28 DESCRIPTION
29 }
30  
31 sub command_names
32 {
33 qw(
34 aliases
35 );
36 }
37  
38 sub opt_spec
39 {
40 return;
41 }
42  
43 sub execute
44 {
45 my ($self, $opt, $args) = @_;
46
47 require match::smart;
48 my $filter = scalar(@$args)
49 ? $args
50 : sub { !match::smart::match(shift, [qw(aliases commands help)]) };
51
52 foreach my $cmd (sort $self->app->command_plugins)
53 {
54 my ($preferred, @aliases) = $cmd->command_names;
55 printf("%-16s: %s\n", $preferred, "@aliases")
56 if match::smart::match($preferred, $filter);
57 }
58 }
59  
60 1;