Skip to content

Commit

Permalink
Term::ANSIColor is a core module since 5.6. Removed the debugging +1
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Feb 23, 2009
1 parent 0bf3ea1 commit 481e06b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tools/refresh
Expand Up @@ -4,11 +4,7 @@ use warnings;
use LWP::UserAgent;
use HTTP::Request::Common;
use JSON::XS;

eval { require Term::ANSIColor };
my $color = $@
? sub { shift; @_ } # do nothing
: sub { Term::ANSIColor::colored([ shift ], @_) };
use Term::ANSIColor;

my $ua = LWP::UserAgent->new;
$ua->default_header('X-Remedie-Client' => 'CLI');
Expand All @@ -32,9 +28,9 @@ my @channels = @ARGV ? get_channels(@ARGV) : all_channels();

for my $channel (@channels) {
my $data = $api_call->("post", "/channel/refresh", { id => $channel->{id} });
my $new = $data->{channel}{unwatched_count} - $channel->{unwatched_count} + 1;
warn sprintf "%d: %s updated %s\n",
$channel->{id}, $data->{channel}{name}, ($new ? $color->('red', "($new)") : "");
my $new = $data->{channel}{unwatched_count} - $channel->{unwatched_count};
printf "%d: %s updated %s\n",
$channel->{id}, $data->{channel}{name}, ($new ? colored(['red'], "($new)") : "");
}

sub get_channels {
Expand Down

0 comments on commit 481e06b

Please sign in to comment.