| 1 | package CLI::Framework::Command::List; | ||
| 2 | use base qw( CLI::Framework::Command::Meta ); | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | our $VERSION = 0.01; | ||
| 8 | |||
| 9 | #------- | ||
| 10 | |||
| 11 | sub usage_text { | ||
| 12 | q{ | ||
| 13 | list: print a concise list of the names of all commands available to the application | ||
| 14 | } | ||
| 15 | } | ||
| 16 | |||
| 17 | sub run { | ||
| 18 | my ($self, $opts, @args) = @_; | ||
| 19 | |||
| 20 | my $app = $self->get_app(); # metacommand is app-aware | ||
| 21 | |||
| 22 | # If interactive, exclude commands that do not apply in interactive mode... | ||
| 23 | my @command_set = $app->get_interactivity_mode() | ||
| 24 | ? $app->get_interactive_commands() | ||
| 25 | : keys %{ $app->command_map_hashref() }; | ||
| 26 | |||
| 27 | my $result = join(', ', map { lc $_ } @command_set ) . "\n"; | ||
| 28 | return $result; | ||
| 29 | } | ||
| 30 | |||
| 31 | #------- | ||
| 32 | 1; | ||
| 33 | |||
| 34 | __END__ |