™.. CPANPLUS::Shell::Default::Plugins::HOWTO - Online Linux Manual PageSection : 3pm
Updated : 2009-05-03
Source : perl v5.10.1
Note : Perl Programmers Reference Guide
NAMECPANPLUS::Shell::Default::Plugins::HOWTO −− documentation on how to write your own plugins
SYNOPSIS package CPANPLUS::Shell::Default::Plugins::MyPlugin;
### return command => method mapping
sub plugins { ( myplugin1 => 'mp1', myplugin2 => 'mp2' ) }
### method called when the command '/myplugin1' is issued
sub mp1 { .... }
### method called when the command '/? myplugin1' is issued
sub mp1_help { return "Help Text" }
DESCRIPTIONThis pod text explains how to write your own plugins for \*(C`CPANPLUS::Shell::Default\*(C'\fR.
HOWTO
Registering Plugin ModulesPlugins are detected by using \*(C`Module::Pluggable\*(C'\fR. Every module in the \*(C`CPANPLUS::Shell::Default::Plugins::*\*(C'\fR namespace is considered a plugin, and is attempted to be loaded. Therefor, any plugin must be declared in that namespace, in a corresponding \*(C`.pm\*(C'\fR file.
Registering Plugin CommandsTo register any plugin commands, a list of key value pairs must be returned by a \*(C`plugins\*(C'\fR method in your package. The keys are the commands you wish to register, the values are the methods in the plugin package you wish to have called when the command is issued. For example, a simple 'Hello, World!' plugin: package CPANPLUS::Shell::Default::Plugins::HW;
sub plugins { return ( helloworld => 'hw' ) };
sub hw { print "Hello, world!\n" }
When the user in the default shell now issues the \*(C`/helloworld\*(C'\fR command, this command will be dispatched to the plugin, and its \*(C`hw\*(C'\fR method will be called
Registering Plugin HelpTo provide usage information for your plugin, the user of the default shell can type \*(C`/? PLUGIN_COMMAND\*(C'\fR. In that case, the function \f(CW\*(C`PLUGIN_COMMAND_help\*(C'\fR will be called in your plugin package. For example, extending the above example, when a user calls \*(C`/? helloworld\*(C'\fR, the function \*(C`hw_help\*(C'\fR will be called, which might look like this: sub hw_help { " /helloworld # prints "Hello, world!\n" }
If you dont provide a corresponding _help function to your commands, the default shell will handle it gracefully, but the user will be stuck without usage information on your commands, so it's considered undesirable to omit the help functions.
Arguments to Plugin CommandsAny plugin function will receive the following arguments when called, which are all positional: Classname \*(-- The name of your plugin class Shell \*(-- The CPANPLUS::Shell::Default object Backend \*(-- The CPANPLUS::Backend object Command \*(-- The command issued by the user Input \*(-- The input string from the user Options \*(-- A hashref of options provided by the user For example, the following command: /helloworld bob −−nofoo −−bar=2 joe
Would yield the following arguments: sub hw {
my $class = shift; # CPANPLUS::Shell::Default::Plugins::HW
my $shell = shift; # CPANPLUS::Shell::Default object
my $cb = shift; # CPANPLUS::Backend object
my $cmd = shift; # 'helloworld'
my $input = shift; # 'bob joe'
my $opts = shift; # { foo => 0, bar => 2 }
....
}
BUG REPORTSPlease report bugs or other issues to <bug−cpanplus@rt.cpan.org<gt>.
AUTHORThis module by Jos Boumans <kane@cpan.org>.
COPYRIGHTThe CPAN++ interface (of which this module is a part of) is copyright (c) 2001 − 2007, Jos Boumans <kane@cpan.org>. All rights reserved. This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.
SEE ALSOCPANPLUS::Shell::Default, CPANPLUS::Shell, cpanp 0
Johanes Gumabo
Data Size : 13,473 byte
man-CPANPLUS::Shell::Default::Plugins::HOWTO.3pmBuild : 2024-12-29, 07:25 :
Visitor Screen : x
Visitor Counter ( page / site ) : 7 / 257,193
Visitor ID : :
Visitor IP : 3.142.42.247 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.29
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|252|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|252|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|41|br══─}─══|'br══─}─══
) (htmlprn|149|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|41|'br══─}─══ |'br══─}─══
) (rof_nr_x|149|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (rof_unit_scale_px|41|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|51/52|F|.ie \nF ══─{─══. de IX
) (rof_if|19|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (htmlprn|149|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|51/52|.ie \nF ══─{─══. de IX|.ie \nF ══─{─══. de IX
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|53|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2"
) (parse_manual_page_|252|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|57|══─}─══|.══─}─══
) (htmlprn|149|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|57|.══─}─══ |.══─}─══
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|151|\*(C`CPANPLUS::Shell::Default\*(C'\fR. |\&\f(CW\*(C`CPANPLUS::Shell::Default\*(C'\fR.
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|156|\*(C`Module::Pluggable\*(C'\fR. Every module in |Plugins are detected by using \f(CW\*(C`Module::Pluggable\*(C'\fR. Every module in
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|157|\*(C`CPANPLUS::Shell::Default::Plugins::*\*(C'\fR namespace is considered a |the \f(CW\*(C`CPANPLUS::Shell::Default::Plugins::*\*(C'\fR namespace is considered a
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|161|\*(C`.pm\*(C'\fR file. |\&\f(CW\*(C`.pm\*(C'\fR file.
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|165|\*(C`plugins\*(C'\fR method in your package. The keys are the commands you wish |by a \f(CW\*(C`plugins\*(C'\fR method in your package. The keys are the commands you wish
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|179|\*(C`/helloworld\*(C'\fR command, |When the user in the default shell now issues the \f(CW\*(C`/helloworld\*(C'\fR command,
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|180|\*(C`hw\*(C'\fR method will |this command will be dispatched to the plugin, and its \f(CW\*(C`hw\*(C'\fR method will
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|185|\*(C`/? PLUGIN_COMMAND\*(C'\fR. In that case, the function \f(CW\*(C`PLUGIN_COMMAND_help\*(C'\fR |can type \f(CW\*(C`/? PLUGIN_COMMAND\*(C'\fR. In that case, the function \f(CW\*(C`PLUGIN_COMMAND_help\*(C'\fR
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|188|\*(C`/? helloworld\*(C'\fR, |For example, extending the above example, when a user calls \f(CW\*(C`/? helloworld\*(C'\fR,
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|189|\*(C`hw_help\*(C'\fR will be called, which might look like this: |the function \f(CW\*(C`hw_help\*(C'\fR will be called, which might look like this:
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|203|\*(-- The name of your plugin class" 4 |.IP "Classname \*(-- The name of your plugin class" 4
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|206|\*(-- The CPANPLUS::Shell::Default object" 4 |.IP "Shell \*(-- The CPANPLUS::Shell::Default object" 4
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|208|\*(-- The CPANPLUS::Backend object" 4 |.IP "Backend \*(-- The CPANPLUS::Backend object" 4
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|210|\*(-- The command issued by the user" 4 |.IP "Command \*(-- The command issued by the user" 4
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|212|\*(-- The input string from the user" 4 |.IP "Input \*(-- The input string from the user" 4
) (rof_escape_sequence|91|CPANPLUS::Shell::Default::Plugins::HOWTO.3pm|214|\*(-- A hashref of options provided by the user" 4 |.IP "Options \*(-- A hashref of options provided by the user" 4
)