From 2ebeaf1cc5192f78e5ac110fabd2ac4a9afcc707 Mon Sep 17 00:00:00 2001 From: Andinus Date: Thu, 19 Nov 2020 12:12:37 +0530 Subject: Add option to print version, bump version to v0.1.1 --- draco.pl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/draco.pl b/draco.pl index 908f3de..a926246 100755 --- a/draco.pl +++ b/draco.pl @@ -10,12 +10,21 @@ use JSON::MaybeXS; use Unicode::LineBreak; my $lb = Unicode::LineBreak->new(ColMax => 76); # Default is 76. -my $VERSION = "v0.1.0"; - # Printing UTF-8 to STDOUT. binmode(STDOUT, "encoding(UTF-8)"); -die "usage: draco \n" unless scalar @ARGV; +my $VERSION = "v0.1.1"; + +die "usage: draco [-v] \n" unless scalar @ARGV; + +# Dispatch table to be parsed before url. +my %dispatch = ( + '-v' => sub { print "Draco $VERSION\n"; exit; }, +); +if (exists $dispatch{$ARGV[0]}) { + # shift @ARGV to get $url in next shift. + $dispatch{shift @ARGV}->(); +} # $url contains the reddit post. my $url = shift @ARGV; -- cgit 1.4.1-2-gfad0