summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-11-19 12:12:37 +0530
committerAndinus <andinus@nand.sh>2020-11-19 12:12:37 +0530
commit2ebeaf1cc5192f78e5ac110fabd2ac4a9afcc707 (patch)
tree3bc91d6db6355cbc41202a1bcee00f17e0bdf841
parentb554dc05d4439364da2e49ae8abe05b6c3a0e786 (diff)
downloaddraco-2ebeaf1cc5192f78e5ac110fabd2ac4a9afcc707.tar.gz
Add option to print version, bump version to v0.1.1
-rwxr-xr-xdraco.pl15
1 files 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 <url>\n" unless scalar @ARGV;
+my $VERSION = "v0.1.1";
+
+die "usage: draco [-v] <url>\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;