/usr/share/perl5/CLI/Framework/Command/Menu.pm is in libcli-framework-perl 0.05-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | package CLI::Framework::Command::Menu;
use base qw( CLI::Framework::Command::Meta );
use strict;
use warnings;
our $VERSION = 0.01;
#-------
sub usage_text {
q{
menu: menu of available commands
}
}
sub run {
my ($self, $opts, @args) = @_;
return $self->menu_txt();
}
sub menu_txt {
my ($self) = @_;
my $app = $self->get_app();
# Build a numbered list of visible commands...
my @cmd = $app->get_interactive_commands();
my $txt;
my %new_aliases = $app->command_alias();
for my $i (0..$#cmd) {
my $alias = $i+1;
$txt .= $alias . ') ' . $cmd[$i] . "\n";
$new_aliases{$alias} = $cmd[$i];
}
# Add numerical aliases corresponding to menu options to the original
# command aliases defined by the application...
{
no strict 'refs'; no warnings;
*{ (ref $app).'::command_alias' } = sub { %new_aliases };
return "\n".$txt;
}
}
sub line_count {
my ($self) = @_;
my $menu = $self->menu_txt();
my $line_count = 0;
$line_count++ while $menu =~ /\n/g;
return $line_count;
}
#-------
1;
__END__
=pod
=head1 NAME
CLI::Framework::Command::Menu - CLIF built-in command to show a command menu
including the commands that are available to the running application
=head1 SEE ALSO
L<run_interactive|CLI::Framework::Application/run_interactive( [%param] )>
L<CLI::Framework::Command::Console>
L<CLI::Framework::Command>
=cut
|