diff options
author | Andinus <andinus@nand.sh> | 2020-11-20 10:21:58 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-11-20 10:21:58 +0530 |
commit | 56e880f5028d9f1892d1af28007ab6a7108ad977 (patch) | |
tree | c4197d49ad23775394753d76b2a11c32ae241d1c | |
parent | 61266c6e9a39a75875531dfb24852b6e9eef6f1a (diff) | |
download | draco-56e880f5028d9f1892d1af28007ab6a7108ad977.tar.gz |
Add debug option, bump version to v0.1.3 v0.1.3
-rw-r--r-- | draco.1 | 9 | ||||
-rwxr-xr-x | draco.pl | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/draco.1 b/draco.1 index c08be26..d68912b 100644 --- a/draco.1 +++ b/draco.1 @@ -6,7 +6,7 @@ .Nd a script to convert reddit thread to Org document .Sh SYNOPSIS .Nm draco -.Op -v +.Op Fl dv .Ar <url> .Sh DESCRIPTION .Nm @@ -15,6 +15,13 @@ is a script to convert reddit thread to Org document. It accepts a url It'll also print comments along with their replies. It's limited by the reddit API. + +The options are as follows: +.Bl -tag -width Ds +.It Fl d +Turn on debug messages. Debug messages will be printed to STDERR. +.It Fl v +Print version. .Pp .Sh NOTES Draco will add 2 spaces before every new line. Comments/Posts may 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] <url>\n" unless scalar @ARGV; +die "usage: draco [-dv] <url>\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 |