]> Dogcows Code - chaz/git-codeowners/blobdiff - lib/App/Codeowners/Options.pm
Version 0.49
[chaz/git-codeowners] / lib / App / Codeowners / Options.pm
index 950f0b89a1635dfa53d0387432fed9ffecd7ec5e..db7261e0a2bf87eab8f8e1902df65277f4efe315 100644 (file)
@@ -1,14 +1,36 @@
 package App::Codeowners::Options;
 # ABSTRACT: Getopt and shell completion for App::Codeowners
 
+use v5.10.1;
 use warnings;
 use strict;
 
+use Encode qw(decode);
 use Getopt::Long 2.39 ();
 use Path::Tiny;
-use Pod::Usage;
 
-our $VERSION = '0.41'; # VERSION
+our $VERSION = '0.49'; # 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 {
@@ -30,8 +52,13 @@ sub command_options {
         'patterns'  => {
             'owner=s'   => '',
         },
+        'projects'  => {},
         'show'      => {
-            'project!'  => 1,
+            'owner=s@'      => [],
+            'pattern=s@'    => [],
+            'project=s@'    => [],
+            'patterns!'     => 0,
+            'projects!'     => undef,
         },
         'update'    => {},
     };
@@ -56,6 +83,9 @@ sub new {
     my $class = shift;
     my @args  = @_;
 
+    # assume UTF-8 args if non-ASCII
+    @args = map { decode('UTF-8', $_) } @args if grep { /\P{ASCII}/ } @args;
+
     my $self = bless {}, $class;
 
     my @args_copy = @args;
@@ -84,7 +114,7 @@ sub new {
         exit 0;
     }
     if ($opts->{help}) {
-        pod2usage(-exitval => 0, -verbose => 99, -sections => [qw(NAME SYNOPSIS OPTIONS)]);
+        pod2usage(-exitval => 0, -verbose => 99, -sections => [qw(NAME SYNOPSIS OPTIONS COMMANDS)]);
     }
     if ($opts->{manual}) {
         pod2usage(-exitval => 0, -verbose => 2);
@@ -273,7 +303,7 @@ App::Codeowners::Options - Getopt and shell completion for App::Codeowners
 
 =head1 VERSION
 
-version 0.41
+version 0.49
 
 =head1 METHODS
 
This page took 0.025597 seconds and 4 git commands to generate.