| 1 |
=begin |
| 2 |
|
| 3 |
=head1 Adding a New Command |
| 4 |
|
| 5 |
Read on if you would like to add a new command to Plumage, so that the |
| 6 |
user can say C<plumage foo> for some new C<foo>. |
| 7 |
|
| 8 |
|
| 9 |
=head2 Before You Start |
| 10 |
|
| 11 |
Make sure that any new I<functionality> exists in the C<Plumage::*> |
| 12 |
libraries, so that it can be accessed by scripts or any UI. This document |
| 13 |
only explains how to expose I<existing> library functionality through the |
| 14 |
default CLI interface. |
| 15 |
|
| 16 |
If the new command is a project action, first follow the instructions to |
| 17 |
L<Add a New Project Action|add-action.pod> before coming back here. |
| 18 |
|
| 19 |
=head2 Base Implementation |
| 20 |
|
| 21 |
To add a new command to the C<plumage> command-line tool, you will currently |
| 22 |
need to update F<src/plumage.nqp> in three places: |
| 23 |
|
| 24 |
=over 4 |
| 25 |
|
| 26 |
=item * Add a new F<command_> sub implementing the new command at a logical spot in the C<COMMANDS> section. |
| 27 |
|
| 28 |
=item * Add a new entry to C<%COMMANDS> near the top of the file to enable the new command. |
| 29 |
|
| 30 |
=item * Update the C<usage_info> sub at the top of the C<COMMANDS> section so that the user can find it. |
| 31 |
|
| 32 |
=back |
| 33 |
|
| 34 |
If the command is a project action, you can skip the first step above and |
| 35 |
simply reuse C<command_project_action()>, which provides default behavior |
| 36 |
for any project action. You will still need to do the remaining steps above, |
| 37 |
of course. |
| 38 |
|
| 39 |
|
| 40 |
=head2 Tests |
| 41 |
|
| 42 |
You should also add tests for your new command in the F<t/> directory. |
| 43 |
There should be at least four kinds of tests for every command: |
| 44 |
|
| 45 |
=over 4 |
| 46 |
|
| 47 |
=item Null tests |
| 48 |
|
| 49 |
The command should do something sane (usually complain to the user) if it |
| 50 |
requires arguments but none were provided. |
| 51 |
|
| 52 |
=item Fuzz tests |
| 53 |
|
| 54 |
The command should behave itself and error out when presented with bad |
| 55 |
arguments. |
| 56 |
|
| 57 |
=item Environment tests |
| 58 |
|
| 59 |
The command should similarly behave itself when presented with a bad |
| 60 |
environment (bad permissions, incorrect settings, invalid state info, etc.). |
| 61 |
This could mean erroring out, or it could mean fixing the problem (with |
| 62 |
appropriate user notification). |
| 63 |
|
| 64 |
=item Correctness tests |
| 65 |
|
| 66 |
Of course, given correct arguments and a valid environment, the command |
| 67 |
should actually do what claims to do. |
| 68 |
|
| 69 |
=back |
| 70 |
|
| 71 |
|
| 72 |
=head2 Documentation |
| 73 |
|
| 74 |
The F<plumage> command line tool does not currently have a full manpage; |
| 75 |
when it does, you will need to add documentation for your command there |
| 76 |
as well. |
| 77 |
|
| 78 |
=end |