The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Commandable::Finder::Packages - find commands stored per package

SYNOPSIS

   use Commandable::Finder::Packages;

   my $finder = Commandable::Finder::Packages->new(
      base => "MyApp::Command",
   );

   my $help_command = $finder->find_command( "help" );

   foreach my $command ( $finder->find_commands ) {
      ...
   }

DESCRIPTION

This implementation of Commandable::Finder looks for implementations of commands, where each command is implemented by a different package somewhere in the symbol table.

This class uses Module::Pluggable to load packages from the filesystem. As commands are located per package (and not per file), the application can provide special-purpose internal commands by implementing more packages in the given namespace, regardless of which files they come from.

CONSTRUCTOR

new

   $finder = Commandable::Finder::Packages->new( %args )

Constructs a new instance of Commandable::Finder::Packages.

Takes the following named arguments:

base => STR

The base of the package namespace to look inside for packages that implement commands.

name_method => STR

Optional. Gives the name of the method inside each command package to invoke to generate the name of the command. Default COMMAND_NAME.

description_method => STR

Optional. Gives the name of the method inside each command package to invoke to generate the description text of the command. Default COMMAND_DESC.

named_by_package => BOOL

Optional. If true, the name of each command will be taken from its package name. with the leading base string removed. If absent or false, the name_method will be used instead.

If either name or description method are missing from a package, that package is silently ignored.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>