combined limit minimum-maximum
[barcat.git] / barcat
diff --git a/barcat b/barcat
index c4244d4e61d5e99d4c80d6432387782f27d4296d..a69bbe520e735ba27a8736b6939891994208badb 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -30,8 +30,15 @@ GetOptions(\%opt,
        },
        'value-length=i',
        'hidemin=i',
-       'hidemax|limit|L=i' => sub {
-               $opt{$_[1] < 0 ? 'hidemin' : 'hidemax'} = abs $_[1];
+       'hidemax=i',
+       'limit|L=s' => sub {
+               my ($optname, $optval) = @_;
+               $optval ||= 0;
+               ($opt{hidemin}, $opt{hidemax}) =
+               $optval =~ m/\A (?: ([0-9]+)? - )? ([0-9]+)? \z/x or die(
+                       "Value \"$optval\" invalid for option limit",
+                       " (range expected)\n"
+               );
        },
        'markers|m=s',
        'unmodified|u!',
@@ -190,7 +197,7 @@ unless C<--length=0>.
 Prepend a dash (i.e. make negative) to enforce padding
 regardless of encountered contents.
 
-=item -L, --limit=[-]<count>
+=item -L, --limit=(<count>|<start>-[<end>])
 
 Stop output after a number of lines.
 All input is still counted and analyzed for statistics,