1App::Cmd::Setup(3) User Contributed Perl Documentation App::Cmd::Setup(3)
2
3
4
6 App::Cmd::Setup - helper for setting up App::Cmd classes
7
9 version 0.331
10
12 App::Cmd::Setup is a helper library, used to set up base classes that
13 will be used as part of an App::Cmd program. For the most part you
14 should refer to the tutorial for how you should use this library.
15
16 This class is useful in three scenarios:
17
18 when writing your App::Cmd subclass
19 Instead of writing:
20
21 package MyApp;
22 use base 'App::Cmd';
23
24 ...you can write:
25
26 package MyApp;
27 use App::Cmd::Setup -app;
28
29 The benefits of doing this are mostly minor, and relate to sanity-
30 checking your class. The significant benefit is that this form
31 allows you to specify plugins, as in:
32
33 package MyApp;
34 use App::Cmd::Setup -app => { plugins => [ 'Prompt' ] };
35
36 Plugins are described in App::Cmd::Tutorial and App::Cmd::Plugin.
37
38 when writing abstract base classes for commands
39 That is: when you write a subclass of App::Cmd::Command that is
40 intended for other commands to use as their base class, you should
41 use App::Cmd::Setup. For example, if you want all the commands in
42 MyApp to inherit from MyApp::Command, you may want to write that
43 package like this:
44
45 package MyApp::Command;
46 use App::Cmd::Setup -command;
47
48 Do not confuse this with the way you will write specific commands:
49
50 package MyApp::Command::mycmd;
51 use MyApp -command;
52
53 Again, this form mostly performs some validation and setup behind
54 the scenes for you. You can use "base" if you prefer.
55
56 when writing App::Cmd plugins
57 App::Cmd::Plugin is a mechanism that allows an App::Cmd class to
58 inject code into all its command classes, providing them with
59 utility routines.
60
61 To write a plugin, you must use App::Cmd::Setup. As seen above,
62 you must also use App::Cmd::Setup to set up your App::Cmd subclass
63 if you wish to consume plugins.
64
65 For more information on writing plugins, see App::Cmd::Manual and
66 App::Cmd::Plugin.
67
69 Ricardo Signes <rjbs@cpan.org>
70
72 This software is copyright (c) 2016 by Ricardo Signes.
73
74 This is free software; you can redistribute it and/or modify it under
75 the same terms as the Perl 5 programming language system itself.
76
77
78
79perl v5.30.0 2019-07-26 App::Cmd::Setup(3)