App-Git-Workflow
view release on metacpan or search on metacpan
lib/App/Git/Workflow/Command.pm view on Meta::CPAN
package App::Git::Workflow::Command;
# Created on: 2014-03-11 20:58:59
# Create by: Ivan Wills
# $Id$
# $Revision$, $HeadURL$, $Date$
# $Revision$, $Source$, $Date$
use strict;
use warnings;
use version;
use Getopt::Long;
use Data::Dumper qw/Dumper/;
use English qw/ -no_match_vars /;
use base qw/Exporter/;
our $VERSION = version->new(1.1.20);
our @EXPORT_OK = qw/get_options/;
our %p2u_extra;
sub get_options {
my ($option, @options) = @_;
my ($caller_package) = caller;
$caller_package .= '.pm';
$caller_package =~ s{::}{/}g;
$caller_package = $INC{$caller_package} || $0;
Getopt::Long::Configure('bundling');
GetOptions(
$option,
'verbose|v+',
'man',
'help',
'version!',
@options,
) or pod2usage(
-verbose => 1,
-input => $caller_package,
%p2u_extra,
) and return;
if ( $option->{'version'} ) {
my $name = (caller)[0] . '::name';
no strict qw/refs/; ## no critic
print "${$name} Version = $VERSION\n";
return;
}
elsif ( $option->{'man'} ) {
pod2usage(
-verbose => 2,
-input => $caller_package,
%p2u_extra,
);
return;
}
elsif ( $option->{'help'} ) {
pod2usage(
-verbose => 1,
-input => $caller_package,
%p2u_extra,
);
return;
}
return 1;
}
sub pod2usage {
my %opt = @_;
eval { require Pod::Usage };
if ($@) {
my $found = 0;
open my $fh, '<', $opt{-input};
while ( $_ = <$fh> ) {
if (/^__DATA__$/) {
$found = 1;
}
elsif ($found) {
print $_;
}
}
}
else {
Pod::Usage::pod2usage(@_);
}
return 1;
}
1;
__DATA__
=head1 NAME
App::Git::Workflow::Command - Helper for other commands
=head1 VERSION
This documentation refers to App::Git::Workflow::Command version 1.1.20
=head1 SYNOPSIS
( run in 0.722 second using v1.01-cache-2.11-cpan-ceb78f64989 )