| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::CLI::Command::Commands; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 651 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 32 |  | 
| 4 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 28 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 1 |  |  | 1 |  | 5 | use base qw/App::CLI::Command/; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 317 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head1 NAME | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | App::CLI::Command::Commands - Print a list of commands for your app | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | package MyApp; | 
| 15 |  |  |  |  |  |  | use base qw(App::CLI App::CLI::Command); | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | # Make your app get a list of commands | 
| 18 |  |  |  |  |  |  | use constant alias => ( | 
| 19 |  |  |  |  |  |  | commands => '+App::CLI::Command::Commands', | 
| 20 |  |  |  |  |  |  | ); | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | 1; | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | Print a list of commands registered for your application; | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | =cut | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | sub run { | 
| 31 | 1 |  |  | 1 | 0 | 3 | my ($self) = shift; | 
| 32 |  |  |  |  |  |  |  | 
| 33 | 1 |  |  |  |  | 3 | my ($longest) = sort { length($b) cmp length($a) } $self->app->commands; | 
|  | 0 |  |  |  |  | 0 |  | 
| 34 | 1 |  |  |  |  | 3 | $longest = length $longest; | 
| 35 |  |  |  |  |  |  |  | 
| 36 | 1 |  |  |  |  | 4 | foreach ( $self->app->commands ) { | 
| 37 | 1 |  |  |  |  | 6 | my $cmd        = $self->app->get_cmd($_); | 
| 38 | 1 |  |  |  |  | 6 | my @components = split /::/, ref $cmd; | 
| 39 | 1 |  |  |  |  | 3 | my $name       = lc pop @components; | 
| 40 | 1 |  |  |  |  | 62 | printf "    %${longest}s\n", $name; | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | 1; |