1CPANPLUS::Shell::DefaulUts:e:rPlCuognitnrsi:b:uHtCOePWdATNOPP(eL3rU)lS:D:oSchuemleln:t:aDteifoanult::Plugins::HOWTO(3)
2
3
4

NAME

6       CPANPLUS::Shell::Default::Plugins::HOWTO -- documentation on how to
7       write your own plugins
8

SYNOPSIS

10           package CPANPLUS::Shell::Default::Plugins::MyPlugin;
11
12           ### return command => method mapping
13           sub plugins { ( myplugin1 => 'mp1', myplugin2 => 'mp2' ) }
14
15           ### method called when the command '/myplugin1' is issued
16           sub mp1 { .... }
17
18           ### method called when the command '/? myplugin1' is issued
19           sub mp1_help { return "Help Text" }
20

DESCRIPTION

22       This pod text explains how to write your own plugins for
23       "CPANPLUS::Shell::Default".
24

HOWTO

26   Registering Plugin Modules
27       Plugins are detected by using "Module::Pluggable". Every module in the
28       "CPANPLUS::Shell::Default::Plugins::*" namespace is considered a
29       plugin, and is attempted to be loaded.
30
31       Therefor, any plugin must be declared in that namespace, in a
32       corresponding ".pm" file.
33
34   Registering Plugin Commands
35       To register any plugin commands, a list of key value pairs must be
36       returned by a "plugins" method in your package. The keys are the
37       commands you wish to register, the values are the methods in the plugin
38       package you wish to have called when the command is issued.
39
40       For example, a simple 'Hello, World!' plugin:
41
42           package CPANPLUS::Shell::Default::Plugins::HW;
43
44           sub plugins { return ( helloworld => 'hw' ) };
45
46           sub hw { print "Hello, world!\n" }
47
48       When the user in the default shell now issues the "/helloworld"
49       command, this command will be dispatched to the plugin, and its "hw"
50       method will be called
51
52   Registering Plugin Help
53       To provide usage information for your plugin, the user of the default
54       shell can type "/? PLUGIN_COMMAND". In that case, the function
55       "PLUGIN_COMMAND_help" will be called in your plugin package.
56
57       For example, extending the above example, when a user calls "/?
58       helloworld", the function "hw_help" will be called, which might look
59       like this:
60
61           sub hw_help { "    /helloworld      # prints "Hello, world!\n" }
62
63       If you don't provide a corresponding _help function to your commands,
64       the default shell will handle it gracefully, but the user will be stuck
65       without usage information on your commands, so it's considered
66       undesirable to omit the help functions.
67
68   Arguments to Plugin Commands
69       Any plugin function will receive the following arguments when called,
70       which are all positional:
71
72       Classname -- The name of your plugin class
73       Shell     -- The CPANPLUS::Shell::Default object
74       Backend   -- The CPANPLUS::Backend object
75       Command   -- The command issued by the user
76       Input     -- The input string from the user
77       Options   -- A hashref of options provided by the user
78
79       For example, the following command:
80
81           /helloworld bob --nofoo --bar=2 joe
82
83       Would yield the following arguments:
84
85           sub hw {
86               my $class   = shift;    # CPANPLUS::Shell::Default::Plugins::HW
87               my $shell   = shift;    # CPANPLUS::Shell::Default object
88               my $cb      = shift;    # CPANPLUS::Backend object
89               my $cmd     = shift;    # 'helloworld'
90               my $input   = shift;    # 'bob joe'
91               my $opts    = shift;    # { foo => 0, bar => 2 }
92
93               ....
94           }
95

BUG REPORTS

97       Please report bugs or other issues to <bug-cpanplus@rt.cpan.org<gt>.
98

AUTHOR

100       This module by Jos Boumans <kane@cpan.org>.
101
103       The CPAN++ interface (of which this module is a part of) is copyright
104       (c) 2001 - 2007, Jos Boumans <kane@cpan.org>. All rights reserved.
105
106       This library is free software; you may redistribute and/or modify it
107       under the same terms as Perl itself.
108

SEE ALSO

110       CPANPLUS::Shell::Default, CPANPLUS::Shell, cpanp
111
112
113
114perl v5.36.0                      20C2P2A-N0P7L-U2S2::Shell::Default::Plugins::HOWTO(3)
Impressum