Am Montag, 15. Juni 2015 20:06:02 UTC+2 schrieb sri:
>
> 2. it would be nice if a Mojolicious app could display descriptions and
>> usage on the command line for all Command packages in the app.
>> Currently it picks up only those that have their own files. My command
>> packages are often so short that it's more handy to have them in the app
>> file itself.
>>
>
> I don't think this is possible.
>
> --
> sebastian
>
Below is an example using Symbol::Table (which unfortunately is not in
core).
Martin
- - 8< - - - - - - -
package Mojolicious::Command::task;
use Mojo::Base 'Mojolicious::Command';
has description => 'Run a task';
has usage => "Usage: APPLICATION task [ARGS]\n";
sub run { shift->app->task(@_) };
package main;
use Symbol::Table;
my $package = "Mojolicious::Command";
my $st = Symbol::Table->New('PACKAGE', $package);
foreach my $subpkg (keys(%$st)) {
print "Package $package contains commmand '$subpkg'\n";
my $cmd = "${package}::$subpkg";
print $cmd->new->usage;
}
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.