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