From 56e880f5028d9f1892d1af28007ab6a7108ad977 Mon Sep 17 00:00:00 2001 From: Andinus Date: Fri, 20 Nov 2020 10:21:58 +0530 Subject: Add debug option, bump version to v0.1.3 --- draco.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'draco.pl') diff --git a/draco.pl b/draco.pl index 37e4654..ac67ee9 100755 --- a/draco.pl +++ b/draco.pl @@ -15,13 +15,14 @@ my $lb = Unicode::LineBreak->new(ColMax => 76); # Default is 76. # Printing UTF-8 to STDOUT. binmode(STDOUT, "encoding(UTF-8)"); -my $VERSION = "v0.1.2"; - -die "usage: draco [-v] \n" unless scalar @ARGV; +die "usage: draco [-dv] \n" unless scalar @ARGV; +my $DEBUG; +my $VERSION = "v0.1.3"; # Dispatch table to be parsed before url. my %dispatch = ( '-v' => sub { print "Draco $VERSION\n"; exit; }, + '-d' => sub { $DEBUG = 1; print STDERR "draco: debug on.\n"; }, ); if (exists $dispatch{$ARGV[0]}) { # shift @ARGV to get $url in next shift. @@ -35,11 +36,13 @@ my $json_url = "${url}.json"; my $http = HTTP::Tiny->new( verify_SSL => 1 ); # Fetch the post. +print STDERR "draco: fetching `$json_url'.\n" if $DEBUG; my $response = $http->get($json_url); die "Unexpected response - $response->{status}: $response->{reason}" unless $response->{success}; # Decode json. +print STDERR "draco: decoding json response.\n" if $DEBUG; my $json_data = decode_json($response->{content}); # $post contains post data -- cgit 1.4.1-2-gfad0