| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | # Created on: 2014-03-11 20:58:59 | 
| 3 |  |  |  |  |  |  | # Create by:  Ivan Wills | 
| 4 |  |  |  |  |  |  | # $Id$ | 
| 5 |  |  |  |  |  |  | # $Revision$, $HeadURL$, $Date$ | 
| 6 |  |  |  |  |  |  | # $Revision$, $Source$, $Date$ | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | use strict; | 
| 9 | 22 |  |  | 22 |  | 1457 | use warnings; | 
|  | 22 |  |  |  |  | 39 |  | 
|  | 22 |  |  |  |  | 546 |  | 
| 10 | 22 |  |  | 22 |  | 114 | use version; | 
|  | 22 |  |  |  |  | 37 |  | 
|  | 22 |  |  |  |  | 485 |  | 
| 11 | 22 |  |  | 22 |  | 90 | use Getopt::Long; | 
|  | 22 |  |  |  |  | 36 |  | 
|  | 22 |  |  |  |  | 123 |  | 
| 12 | 22 |  |  | 22 |  | 12356 | use Data::Dumper qw/Dumper/; | 
|  | 22 |  |  |  |  | 161015 |  | 
|  | 22 |  |  |  |  | 88 |  | 
| 13 | 22 |  |  | 22 |  | 2772 | use English qw/ -no_match_vars /; | 
|  | 22 |  |  |  |  | 37 |  | 
|  | 22 |  |  |  |  | 873 |  | 
| 14 | 22 |  |  | 22 |  | 100 | use base qw/Exporter/; | 
|  | 22 |  |  |  |  | 40 |  | 
|  | 22 |  |  |  |  | 133 |  | 
| 15 | 22 |  |  | 22 |  | 5770 |  | 
|  | 22 |  |  |  |  | 42 |  | 
|  | 22 |  |  |  |  | 4621 |  | 
| 16 |  |  |  |  |  |  | our $VERSION   = version->new(1.1.20); | 
| 17 |  |  |  |  |  |  | our @EXPORT_OK = qw/get_options/; | 
| 18 |  |  |  |  |  |  | our %p2u_extra; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | my ($option, @options) = @_; | 
| 21 |  |  |  |  |  |  | my ($caller_package) = caller; | 
| 22 | 104 |  |  | 104 | 1 | 4691 | $caller_package .= '.pm'; | 
| 23 | 104 |  |  |  |  | 319 | $caller_package =~ s{::}{/}g; | 
| 24 | 104 |  |  |  |  | 281 | $caller_package = $INC{$caller_package} || $0; | 
| 25 | 104 |  |  |  |  | 471 |  | 
| 26 | 104 |  | 66 |  |  | 439 | Getopt::Long::Configure('bundling'); | 
| 27 |  |  |  |  |  |  | GetOptions( | 
| 28 | 104 |  |  |  |  | 439 | $option, | 
| 29 | 104 | 100 | 50 |  |  | 3096 | 'verbose|v+', | 
| 30 |  |  |  |  |  |  | 'man', | 
| 31 |  |  |  |  |  |  | 'help', | 
| 32 |  |  |  |  |  |  | 'version!', | 
| 33 |  |  |  |  |  |  | @options, | 
| 34 |  |  |  |  |  |  | ) or pod2usage( | 
| 35 |  |  |  |  |  |  | -verbose => 1, | 
| 36 |  |  |  |  |  |  | -input   => $caller_package, | 
| 37 |  |  |  |  |  |  | %p2u_extra, | 
| 38 |  |  |  |  |  |  | ) and return; | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | if ( $option->{'version'} ) { | 
| 41 |  |  |  |  |  |  | my $name = (caller)[0] . '::name'; | 
| 42 | 100 | 100 |  |  |  | 74642 | no strict qw/refs/; ## no critic | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
| 43 | 1 |  |  |  |  | 4 | print "${$name} Version = $VERSION\n"; | 
| 44 | 22 |  |  | 22 |  | 123 | return; | 
|  | 22 |  |  |  |  | 37 |  | 
|  | 22 |  |  |  |  | 5298 |  | 
| 45 | 1 |  |  |  |  | 2 | } | 
|  | 1 |  |  |  |  | 64 |  | 
| 46 | 1 |  |  |  |  | 9 | elsif ( $option->{'man'} ) { | 
| 47 |  |  |  |  |  |  | pod2usage( | 
| 48 |  |  |  |  |  |  | -verbose => 2, | 
| 49 | 1 |  |  |  |  | 6 | -input   => $caller_package, | 
| 50 |  |  |  |  |  |  | %p2u_extra, | 
| 51 |  |  |  |  |  |  | ); | 
| 52 |  |  |  |  |  |  | return; | 
| 53 |  |  |  |  |  |  | } | 
| 54 | 1 |  |  |  |  | 25 | elsif ( $option->{'help'} ) { | 
| 55 |  |  |  |  |  |  | pod2usage( | 
| 56 |  |  |  |  |  |  | -verbose => 1, | 
| 57 | 2 |  |  |  |  | 11 | -input   => $caller_package, | 
| 58 |  |  |  |  |  |  | %p2u_extra, | 
| 59 |  |  |  |  |  |  | ); | 
| 60 |  |  |  |  |  |  | return; | 
| 61 |  |  |  |  |  |  | } | 
| 62 | 2 |  |  |  |  | 19 |  | 
| 63 |  |  |  |  |  |  | return 1; | 
| 64 |  |  |  |  |  |  | } | 
| 65 | 96 |  |  |  |  | 358 |  | 
| 66 |  |  |  |  |  |  | my %opt = @_; | 
| 67 |  |  |  |  |  |  | eval { require Pod::Usage }; | 
| 68 |  |  |  |  |  |  | if ($@) { | 
| 69 | 7 |  |  | 7 | 1 | 2760 | my $found = 0; | 
| 70 | 7 |  |  |  |  | 18 | open my $fh, '<', $opt{-input}; | 
|  | 7 |  |  |  |  | 2339 |  | 
| 71 | 7 | 50 |  |  |  | 203358 | while ( $_ = <$fh> ) { | 
| 72 | 0 |  |  |  |  | 0 | if (/^__DATA__$/) { | 
| 73 | 0 |  |  |  |  | 0 | $found = 1; | 
| 74 | 0 |  |  |  |  | 0 | } | 
| 75 | 0 | 0 |  |  |  | 0 | elsif ($found) { | 
|  |  | 0 |  |  |  |  |  | 
| 76 | 0 |  |  |  |  | 0 | print $_; | 
| 77 |  |  |  |  |  |  | } | 
| 78 |  |  |  |  |  |  | } | 
| 79 | 0 |  |  |  |  | 0 | } | 
| 80 |  |  |  |  |  |  | else { | 
| 81 |  |  |  |  |  |  | Pod::Usage::pod2usage(@_); | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  |  | 
| 84 | 7 |  |  |  |  | 29 | return 1; | 
| 85 |  |  |  |  |  |  | } | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 7 |  |  |  |  | 276700 | 1; | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =head1 NAME | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | App::Git::Workflow::Command - Helper for other commands | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =head1 VERSION | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | This documentation refers to App::Git::Workflow::Command version 1.1.20 | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | use App::Git::Workflow::Command qw/get_option/; | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | my %option; | 
| 103 |  |  |  |  |  |  | get_options( \%option, 'test|t!', 'quiet|q' ); | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | Does the boilerplate for other command modules. | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | =head1 SUBROUTINES/METHODS | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | =head2 C<get_options ($option_hash, @options)> | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | Just a wrapper for L<Getopt::Long>'s C<GetOptions> which configures bundling | 
| 114 |  |  |  |  |  |  | and adds verbose, help, man and version options. Also if C<GetOptions> fails | 
| 115 |  |  |  |  |  |  | usage info will be displayed. | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | =head2 C<pod2usage ()> | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | Wrapper for L<Pod::Usage>'s C<pod2usage> to work around Windows' Git Bash tool | 
| 120 |  |  |  |  |  |  | missing the library. | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | =head1 DIAGNOSTICS | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =head1 CONFIGURATION AND ENVIRONMENT | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | =head1 DEPENDENCIES | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | =head1 INCOMPATIBILITIES | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | =head1 BUGS AND LIMITATIONS | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | There are no known bugs in this module. | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | Please report problems to Ivan Wills (ivan.wills@gmail.com). | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | Patches are welcome. | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | =head1 AUTHOR | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | Ivan Wills - (ivan.wills@gmail.com) | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | Copyright (c) 2014 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). | 
| 145 |  |  |  |  |  |  | All rights reserved. | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | This module is free software; you can redistribute it and/or modify it under | 
| 148 |  |  |  |  |  |  | the same terms as Perl itself. See L<perlartistic>.  This program is | 
| 149 |  |  |  |  |  |  | distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | 
| 150 |  |  |  |  |  |  | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | 
| 151 |  |  |  |  |  |  | PARTICULAR PURPOSE. | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | =cut |