require Pod::Usage;
Pod::Usage::pod2usage(-exitval => 0, -perldocopt => '-oman', @_);
}
-GetOptions(\my %opt,
+my %opt;
+GetOptions(\%opt,
'color|c!',
'follow|f:i',
- 'trim|length|l=i',
+ 'trim|length|l=s' => sub {
+ my ($optname, $optval) = @_;
+ $optval =~ s/%$// and $opt{trimpct}++;
+ $optval =~ m/^-?[0-9]+$/ or die(
+ "Value \"$optval\" invalid for option $optname",
+ " (number or percentage expected)\n"
+ );
+ $opt{trim} = $optval;
+ },
'markers|m=s',
'unmodified|u!',
'width|w=i',
$opt{width} ||= $ENV{COLUMNS} || 80;
$opt{color} //= -t *STDOUT; # enable on tty
+$opt{trim} *= $opt{width} / 100 if $opt{trimpct};
if (defined $opt{follow}) {
$opt{follow} ||= 1;
Interval to output partial progress.
-=item -l, --length=[-]<size>
+=item -l, --length=[-]<size>[%]
Trim line contents (between number and bars)
to a maximum number of characters.