diff options
| author | Andinus <andinus@nand.sh> | 2020-11-19 12:12:37 +0530 |
|---|---|---|
| committer | Andinus <andinus@nand.sh> | 2020-11-19 12:12:37 +0530 |
| commit | 2ebeaf1cc5192f78e5ac110fabd2ac4a9afcc707 (patch) | |
| tree | 3bc91d6db6355cbc41202a1bcee00f17e0bdf841 | |
| parent | b554dc05d4439364da2e49ae8abe05b6c3a0e786 (diff) | |
| download | draco-2ebeaf1cc5192f78e5ac110fabd2ac4a9afcc707.tar.gz | |
Add option to print version, bump version to v0.1.1
| -rwxr-xr-x | draco.pl | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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; |