Posted on 2012-01-23 08:23:41.637503-08 by wsppan in response to 13614
Re: sub command dispatching confusion
I did not want a subcommand of foo called bar. It seems from your example that if I want a 'property' subcommand called 'foo' I *MUST* have a Class call 'Foo' that inherits from the Property class.
If I want a 'property' subcommand called 'bar' I *MUST" have a class called 'Bar' that inherits from the 'Property' class.
If I want a 'foo' subcommand called 'blarg' I must have a class called 'Blarg' that inherits from the Foo class.

In other words, I can create a Command called 'requeue' that can map to any class that is a subcommand of CLI::Framework::Command (i.e. My::Queue::Command::Baz), via the command_map() method by adding the following to the return list

requeue => 'My::Queue::Command::Baz',


If I wanted to create a subcommand of 'requeue' called 'random', I *Must* create a class called 'Random' that is a subclass of 'My::Queue::Command::Baz'. The command line would look like:

examples/queue --qin=/tmp/qfile --qout=/tmp/qfile requeue random


There seems to be no way for me to name the class anything but 'Random' if I want the correct class to be instantiated when I call the 'random' subcommand of 'requeue'.

The class name for the 'list' subcommand of the 'property' command must be called List.
The class name for the 'set' subcommand of the 'property' command must be called Set.
Otherwise, how does the Property class know which subclass to call since both List and Set are subclasses of Property. How is 'set' mapped to 'Set' and 'list' mapped to List?

Again, my apologies if I have not made myself clear and/or not groking your explanations. Thank you for your patience.
Direct Responses: 13617 | Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.