r65432 - in /branches/upstream/libgetopt-long-descriptive-perl/current: Changes META.yml README lib/Getopt/Long/Descriptive.pm lib/Getopt/Long/Descriptive/Opts.pm lib/Getopt/Long/Descriptive/Usage.pm t/descriptive.t

carnil at users.alioth.debian.org carnil at users.alioth.debian.org
Wed Dec 1 08:41:08 UTC 2010


Author: carnil
Date: Wed Dec  1 08:40:43 2010
New Revision: 65432

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=65432
Log:
[svn-upgrade] new version libgetopt-long-descriptive-perl (0.087)

Modified:
    branches/upstream/libgetopt-long-descriptive-perl/current/Changes
    branches/upstream/libgetopt-long-descriptive-perl/current/META.yml
    branches/upstream/libgetopt-long-descriptive-perl/current/README
    branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive.pm
    branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive/Opts.pm
    branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive/Usage.pm
    branches/upstream/libgetopt-long-descriptive-perl/current/t/descriptive.t

Modified: branches/upstream/libgetopt-long-descriptive-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgetopt-long-descriptive-perl/current/Changes?rev=65432&op=diff
==============================================================================
--- branches/upstream/libgetopt-long-descriptive-perl/current/Changes (original)
+++ branches/upstream/libgetopt-long-descriptive-perl/current/Changes Wed Dec  1 08:40:43 2010
@@ -1,4 +1,8 @@
 Revision history for Getopt-Long-Descriptive
+
+0.087   2010-11-30
+        long option documentation strings are now line-wrapped and aligned
+        correctly (Dave Rolsky)
 
 0.086   2010-09-19
         fix minimum required version of Sub::Exporter

Modified: branches/upstream/libgetopt-long-descriptive-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgetopt-long-descriptive-perl/current/META.yml?rev=65432&op=diff
==============================================================================
--- branches/upstream/libgetopt-long-descriptive-perl/current/META.yml (original)
+++ branches/upstream/libgetopt-long-descriptive-perl/current/META.yml Wed Dec  1 08:40:43 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Getopt-Long-Descriptive
-version:            0.086
+version:            0.087
 abstract:           Getopt::Long, but simpler and more powerful
 author:
     - Hans Dieter Pearcey <hdp at cpan.org>

Modified: branches/upstream/libgetopt-long-descriptive-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgetopt-long-descriptive-perl/current/README?rev=65432&op=diff
==============================================================================
--- branches/upstream/libgetopt-long-descriptive-perl/current/README (original)
+++ branches/upstream/libgetopt-long-descriptive-perl/current/README Wed Dec  1 08:40:43 2010
@@ -2,7 +2,7 @@
 
 VERSION
 
-0.086
+0.087
 
 INSTALLATION
 

Modified: branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive.pm?rev=65432&op=diff
==============================================================================
--- branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive.pm (original)
+++ branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive.pm Wed Dec  1 08:40:43 2010
@@ -18,11 +18,11 @@
 
 =head1 VERSION
 
-Version 0.086
+Version 0.087
 
 =cut
 
-our $VERSION = '0.086';
+our $VERSION = '0.087';
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive/Opts.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive/Opts.pm?rev=65432&op=diff
==============================================================================
--- branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive/Opts.pm (original)
+++ branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive/Opts.pm Wed Dec  1 08:40:43 2010
@@ -10,11 +10,11 @@
 
 =head1 VERSION
 
-Version 0.086
+Version 0.087
 
 =cut
 
-our $VERSION = '0.086';
+our $VERSION = '0.087';
 
 =head1 DESCRIPTION
 

Modified: branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive/Usage.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive/Usage.pm?rev=65432&op=diff
==============================================================================
--- branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive/Usage.pm (original)
+++ branches/upstream/libgetopt-long-descriptive-perl/current/lib/Getopt/Long/Descriptive/Usage.pm Wed Dec  1 08:40:43 2010
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.086';
+our $VERSION = '0.087';
 
 use List::Util qw(max);
 
@@ -100,10 +100,37 @@
     $spec = Getopt::Long::Descriptive->_strip_assignment($spec);
     $spec = join " ", reverse map { length > 1 ? "--$_" : "-$_" }
                               split /\|/, $spec;
-    $string .= sprintf "$spec_fmt  %s\n", $spec, $desc;
+
+    my @desc = $self->_split_description($length, $desc);
+
+    $string .= sprintf "$spec_fmt  %s\n", $spec, shift @desc;
+    for my $line (@desc) {
+        $string .= "\t";
+        $string .= q{ } x ( $length + 2 );
+        $string .= "$line\n";
+    }
   }
 
   return $string;
+}
+
+sub _split_description {
+  my ($self, $length, $desc) = @_;
+
+  # 8 for a tab, 2 for the space between option & desc;
+  my $max_length = 78 - ( $length + 8 + 2 );
+
+  return $desc if length $desc <= $max_length;
+
+  my @lines;
+  while (length $desc > $max_length) {
+    my $idx = rindex( substr( $desc, 0, $max_length ), q{ }, );
+    push @lines, substr($desc, 0, $idx);
+    substr($desc, 0, $idx + 1) = q{};
+  }
+  push @lines, $desc;
+
+  return @lines;
 }
 
 =head2 warn

Modified: branches/upstream/libgetopt-long-descriptive-perl/current/t/descriptive.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgetopt-long-descriptive-perl/current/t/descriptive.t?rev=65432&op=diff
==============================================================================
--- branches/upstream/libgetopt-long-descriptive-perl/current/t/descriptive.t (original)
+++ branches/upstream/libgetopt-long-descriptive-perl/current/t/descriptive.t Wed Dec  1 08:40:43 2010
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 37;
+use Test::More tests => 38;
 
 use_ok("Getopt::Long::Descriptive");
 
@@ -252,3 +252,24 @@
   is($opt->foo_bar, 1, 'given value (checked with method)');
   is($opt->foo,     1, 'implied value (checked with method)');
 }
+
+{
+  local @ARGV;
+  my ($opt, $usage) = describe_options(
+    "%c %o",
+    [ foo => "a foo option" ],
+    [ bar => "a bar option" ],
+    [ baz => "a baz option with a very long description."
+             . " It just goes on for a really long time."
+             . " This allows us to test line wrapping and"
+             . " make sure the output always looks spiffy" ],
+  );
+
+  my $expect = qr/
+	--baz    a baz option with a very long description. It just goes on
+	         for a really long time. This allows us to test line wrapping
+	         and make sure the output always looks spiffy/;
+
+
+  like($usage->text, $expect, 'long option description is wrapped cleanly');
+}




More information about the Pkg-perl-cvs-commits mailing list