]> Dogcows Code - chaz/git-codeowners/commitdiff
make Pod::Usage optional
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 15 Nov 2019 05:25:36 +0000 (22:25 -0700)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 15 Nov 2019 05:29:20 +0000 (22:29 -0700)
dist.ini
lib/App/Codeowners/Options.pm

index 3574581acbd8e02920375e7d50332af6c861da99..8a066dec96a8d708fade0f0d4cae7fbb76a162cf 100644 (file)
--- a/dist.ini
+++ b/dist.ini
@@ -20,13 +20,15 @@ run                 = %x maint%pbranch_solo.pl %v %d
 
 [RemovePhasedPrereqs]
 remove_runtime      = JSON::MaybeXS
+remove_runtime      = Pod::Usage
 remove_runtime      = Text::CSV
 remove_runtime      = Text::Table::Any
 remove_runtime      = Unicode::GCString
 remove_runtime      = YAML
 [Prereqs / RuntimeRecommends]
-Unicode::GCString       = 0
+Pod::Usage              = 0
 Term::Detect::Software  = 0
+Unicode::GCString       = 0
 [Prereqs / RuntimeSuggests]
 JSON::MaybeXS       = 0
 Text::CSV           = 0
index 7b43b75cc5e5d0272af568bbaea4979cbfb4755c..3c1eb1d26381717147eeb3dcd833c324989ee152 100644 (file)
@@ -1,15 +1,36 @@
 package App::Codeowners::Options;
 # ABSTRACT: Getopt and shell completion for App::Codeowners
 
+use v5.10.1;
 use warnings;
 use strict;
 
 use Getopt::Long 2.39 ();
 use Path::Tiny;
-use Pod::Usage;
 
 our $VERSION = '9999.999'; # VERSION
 
+sub pod2usage {
+    eval { require Pod::Usage };
+    if ($@) {
+        my $ref  = $VERSION eq '9999.999' ? 'master' : "v$VERSION";
+        my $exit = (@_ == 1 && $_[0] =~ /^\d+$/ && $_[0]) //
+                   (@_ % 2 == 0 && {@_}->{'-exitval'})    // 2;
+        print STDERR <<END;
+Online documentation is available at:
+
+  https://github.com/chazmcgarvey/git-codeowners/blob/$ref/README.md
+
+Tip: To enable inline documentation, install the Pod::Usage module.
+
+END
+        exit $exit;
+    }
+    else {
+        Pod::Usage::pod2usage(@_);
+    }
+}
+
 sub early_options {
     return {
         'color|colour!'         => (-t STDOUT ? 1 : 0), ## no critic (InputOutput::ProhibitInteractiveTest)
This page took 0.025892 seconds and 4 git commands to generate.