line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::Framework::Command::Menu; |
2
|
1
|
|
|
1
|
|
2455
|
use base qw( CLI::Framework::Command::Meta ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
88
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
331
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 0.01; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#------- |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub usage_text { |
12
|
0
|
|
|
0
|
1
|
|
q{ |
13
|
|
|
|
|
|
|
menu: menu of available commands |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub run { |
18
|
0
|
|
|
0
|
1
|
|
my ($self, $opts, @args) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
return $self->menu_txt(); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub menu_txt { |
24
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
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
|
|
|
1
|
|
7
|
no strict 'refs'; no warnings; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
304
|
|
|
0
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
|
|
*{ (ref $app).'::command_alias' } = sub { %new_aliases }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return "\n".$txt; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub line_count { |
48
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $menu = $self->menu_txt(); |
51
|
0
|
|
|
|
|
|
my $line_count = 0; |
52
|
0
|
|
|
|
|
|
$line_count++ while $menu =~ /\n/g; |
53
|
0
|
|
|
|
|
|
return $line_count; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#------- |
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |