| 1 | package Gruntmaster::App::Command; |
| 2 | |
| 3 | use 5.014000; |
| 4 | use strict; |
| 5 | use warnings; |
| 6 | use re '/s'; |
| 7 | |
| 8 | our $VERSION = '5999.000_004'; |
| 9 | |
| 10 | use parent qw/App::Cmd::Command/; |
| 11 | use Pod::Usage; |
| 12 | |
| 13 | sub description { |
| 14 | my ($self) = @_; |
| 15 | my ($file) = (ref $self) =~ s,::,/,gr; |
| 16 | my $usage; |
| 17 | open my $fh, '>', \$usage; ## no critic (RequireCheckedOpen) |
| 18 | pod2usage(-input => $INC{"$file.pm"}, -output => $fh, -exitval => 'NOEXIT', -verbose => 99, -sections => [qw/SYNOPSIS DESCRIPTION/]); |
| 19 | close $fh; ## no critic (RequireCheckedClose) |
| 20 | $usage =~ s/Usage:/Usage examples:/; |
| 21 | 1 while chomp $usage; |
| 22 | $usage |
| 23 | } |
| 24 | |
| 25 | 1; |
| 26 | __END__ |
| 27 | |
| 28 | =encoding utf-8 |
| 29 | |
| 30 | =head1 NAME |
| 31 | |
| 32 | Gruntmaster::App::Command - Base class for gm commands |
| 33 | |
| 34 | =head1 SYNOPSIS |
| 35 | |
| 36 | package Gruntmaster::App::Command::foo; |
| 37 | use Gruntmaster::App '-command'; |
| 38 | |
| 39 | =head1 DESCRIPTION |
| 40 | |
| 41 | Gruntmaster::App::Command is the base class of all gm commands. Its |
| 42 | only role is to extract a command's documentation from its POD by |
| 43 | overriding the description method to use L<Pod::Usage>. |
| 44 | |
| 45 | =head1 SEE ALSO |
| 46 | |
| 47 | L<Gruntmaster::App>, L<gm> |
| 48 | |
| 49 | =head1 AUTHOR |
| 50 | |
| 51 | Marius Gavrilescu, E<lt>marius@ieval.roE<gt> |
| 52 | |
| 53 | =head1 COPYRIGHT AND LICENSE |
| 54 | |
| 55 | Copyright (C) 2015 by Marius Gavrilescu |
| 56 | |
| 57 | This library is free software; you can redistribute it and/or modify |
| 58 | it under the same terms as Perl itself, either Perl version 5.20.1 or, |
| 59 | at your option, any later version of Perl 5 you may have available. |
| 60 | |
| 61 | |
| 62 | =cut |