diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-06-03 21:42:49 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-06-03 21:42:49 -0500 |
commit | 6b50bdb6053ee46305ef761a2f6f2a2aee8469b4 (patch) | |
tree | 452edf855ab666148f1a621f936c97799ed94079 | |
parent | 8204dc9150259b35bf3bf5aae16234a0cddf07c5 (diff) | |
download | reply-6b50bdb6053ee46305ef761a2f6f2a2aee8469b4.tar.gz reply-6b50bdb6053ee46305ef761a2f6f2a2aee8469b4.zip |
add some option parsing to the reply script
-rw-r--r-- | bin/reply | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -6,6 +6,7 @@ use warnings; use File::HomeDir; use File::Spec; +use Getopt::Long; use Reply; @@ -24,7 +25,19 @@ this program. =cut -my $cfg = File::Spec->catfile(File::HomeDir->my_home, ".replyrc"); +my $cfgfile = '.replyrc'; +GetOptions( + 'cfg:s' => \$cfgfile, + 'version' => sub { version() }, + 'help' => sub { usage(0) }, +) or usage(1); + +my $cfg = File::Spec->catfile( + (File::Spec->file_name_is_absolute($cfgfile) + ? () + : (File::HomeDir->my_home)), + $cfgfile +); my %args = (config => $cfg); if (!-e $cfg) { @@ -46,6 +59,16 @@ if (!-e $cfg) { Reply->new(%args)->run; +sub usage { + print " reply [--version] [--help] [--cfg file]\n"; + exit($_[0]); +} + +sub version { + print "Reply version $Reply::VERSION\n"; + exit(0); +} + __DATA__ script_line1 = use strict script_line2 = use warnings |