| 1 | package CLI::Framework::Command::Menu; | ||||||||||
| 2 | 1 | ▶ | use base qw( CLI::Framework::Command::Meta ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | our $VERSION = 0.01; | |||||||||
| 8 | |||||||||||
| 9 | #------- | ||||||||||
| 10 | |||||||||||
| 11 | sub usage_text { | ||||||||||
| 12 | 0 | ▶ | q{ | ||||||||
|
Subroutine
usage_text: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 13 | menu: menu of available commands | ||||||||||
| 14 | } | ||||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | sub run { | ||||||||||
| 18 | 0 | ▶ | my ($self, $opts, @args) = @_; | ||||||||
|
Subroutine
run: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 19 | |||||||||||
| 20 | 0 | return $self->menu_txt(); | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | sub menu_txt { | ||||||||||
| 24 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
menu_txt: not called CC=2 SCAR=12.2
Pod
undocumented
| |||||||||||
| 25 | |||||||||||
| 26 | 0 | my $app = $self->get_app(); | |||||||||
| 27 | |||||||||||
| 28 | # Build a numbered list of visible commands... | ||||||||||
| 29 | 0 | my @cmd = $app->get_interactive_commands(); | |||||||||
| 30 | |||||||||||
| 31 | 0 | my $txt; | |||||||||
| 32 | 0 | my %new_aliases = $app->command_alias(); | |||||||||
| 33 | 0 | for my $i (0..$#cmd) { | |||||||||
| 34 | 0 | my $alias = $i+1; | |||||||||
| 35 | 0 | $txt .= $alias . ') ' . $cmd[$i] . "\n"; | |||||||||
| 36 | 0 | $new_aliases{$alias} = $cmd[$i]; | |||||||||
| 37 | } | ||||||||||
| 38 | # Add numerical aliases corresponding to menu options to the original | ||||||||||
| 39 | # command aliases defined by the application... | ||||||||||
| 40 | { | ||||||||||
| 41 | 1 | ▶ | no strict 'refs'; no warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 42 | 0 | ▶ | *{ (ref $app).'::command_alias' } = sub { %new_aliases }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 43 | 0 | return "\n".$txt; | |||||||||
| 44 | } | ||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | sub line_count { | ||||||||||
| 48 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
line_count: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 49 | |||||||||||
| 50 | 0 | my $menu = $self->menu_txt(); | |||||||||
| 51 | 0 | my $line_count = 0; | |||||||||
| 52 | 0 | ▶ | $line_count++ while $menu =~ /\n/g; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 0 | return $line_count; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | #------- | ||||||||||
| 57 | 1 | 1; | |||||||||
| 58 | |||||||||||
| 59 | __END__ | ||||||||||