|
OK, figured it out. Subclass dispatching works like this. It finds all the subclasses of the command class (via inheritance) and adds them to the _subcommands field of the command class:
CLI::Framework::Command::register_subcommand(lib/CLI/Framework/Command.pm:264):
264: my $subcommand_name = $subcommand_obj->name();
CLI::Framework::Command::register_subcommand(lib/CLI/Framework/Command.pm:265):
265: $cmd->{_subcommands}->{$subcommand_name} = $subcommand_obj;
and the name() method is:
sub name {
my ($cmd) = @_;
# Use base name of package as command name...
my $pkg = ref $cmd;
my @pkg_parts = split /::/, $pkg;
return lc $pkg_parts[-1];
}
If I want to use a different subcommand name I can override the name() method in my subcommand class.
Still not sure what happens if I create 2 subcommands classes (no overrides to name()) that inherit from My::Queue::Command::Property:
My::Queue::Command::Property::List
My::Other::Property::List
Which one gets called with the 'list' subcommand?
|