File: manual.pm

package info (click to toggle)
pinto 0.97%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,380 kB
  • ctags: 620
  • sloc: perl: 9,933; sh: 230; makefile: 4
file content (104 lines) | stat: -rw-r--r-- 2,677 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# ABSTRACT: show the full manual for a command

package App::Pinto::Command::manual;

use strict;
use warnings;

use Pod::Usage qw(pod2usage);

use base qw(App::Pinto::Command);

#-------------------------------------------------------------------------------

our $VERSION = '0.097'; # VERSION

#-------------------------------------------------------------------------------

sub command_names { return qw( manual man --man ) }

#-----------------------------------------------------------------------------

sub validate_args {
    my ( $self, $opts, $args ) = @_;

    $self->usage_error("Must specify a command") if @{$args} != 1;

    return 1;
}

#-------------------------------------------------------------------------------
# This was stolen from App::Cmd::Command::help

sub execute {
    my ( $self, $opts, $args ) = @_;

    my ( $cmd, undef, undef ) = $self->app->prepare_command(@$args);

    my $class = ref $cmd;

    # An invalid command name was specified, so the fallback command class 
    # was returned.  Rather than showing the (unhelpful) manual for 
    # App::Cmd::Command::commands, we will just bail out and let App::Cmd
    # show the usual 'unrecognized command' message.
    return 1 if $class eq 'App::Cmd::Command::commands';

    ( my $relative_path = $class ) =~ s< :: ></>xmsg;
    $relative_path .= '.pm';

    my $absolute_path = $INC{$relative_path}
        or die "No manual available for $class\n";

    pod2usage( -verbose => 2, -input => $absolute_path, -exitval => 0 );

    return 1;
}

#-------------------------------------------------------------------------------
1;

__END__

=pod

=encoding UTF-8

=for :stopwords Jeffrey Ryan Thalhammer BenRifkah Fowler Jakob Voss Karen Etheridge Michael
G. Bergsten-Buret Schwern Oleg Gashev Steffen Schwigon Tommy Stanton
Wolfgang Kinkeldei Yanick Boris Champoux hesco popl Däppen Cory G Watson
David Steinbrunner Glenn

=head1 NAME

App::Pinto::Command::manual - show the full manual for a command

=head1 VERSION

version 0.097

=head1 SYNOPSIS

  pinto manual COMMAND

=head1 DESCRIPTION

This command shows the complete user manual for a pinto COMMAND.

=head1 COMMAND ARGUMENTS

The argument to this command is the name of the command for which you would
like to see the manual.  You can also use the L<help|App::Pinto::Command::help> 
command to get a brief summary of the command.

=head1 AUTHOR

Jeffrey Ryan Thalhammer <jeff@stratopan.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Jeffrey Ryan Thalhammer.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut