File: Menu.pm

package info (click to toggle)
libcli-framework-perl 0.05-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 456 kB
  • sloc: perl: 2,168; sql: 18; sh: 3; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,132 bytes parent folder | download | duplicates (3)
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
package My::Journal::Command::Menu;
use base qw( CLI::Framework::Command::Menu );

use strict;
use warnings;

sub usage_text {
    q{
    menu (My::Journal command overriding the built-in): test of overriding a built-in command...'
    }
}

sub menu_txt {
    my ($self) = @_;

    my $app = $self->get_app(); # metacommand is app-aware

    my $menu;
    $menu = "\n" . '-'x13 . "menu" . '-'x13 . "\n";
    for my $c ( $app->get_interactive_commands() ) {
        $menu .= sprintf("\t%s\n", $c)
    }
    $menu .= '-'x30 . "\n";
    return $menu;
}

#-------
1;

__END__

=pod

=head1 NAME

My::Journal::Command::Menu

=head1 PURPOSE

A demonstration and test of overriding a built-in CLIF Menu command.

=head1 NOTES

This example replaces the built-in command menu.  The particular replacement
is not particularly useful, but shows how such a replacement could be done.

Note that overriding the menu command is a special case of overriding a
built-in command and it is necessary that the overriding command inherit from
the built-in menu class, CLI::Framework::Command::Menu.

This example merely changes the menu format.

=cut