summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-06-03 21:42:49 -0500
committerJesse Luehrs <doy@tozt.net>2013-06-03 21:42:49 -0500
commit6b50bdb6053ee46305ef761a2f6f2a2aee8469b4 (patch)
tree452edf855ab666148f1a621f936c97799ed94079
parent8204dc9150259b35bf3bf5aae16234a0cddf07c5 (diff)
downloadreply-6b50bdb6053ee46305ef761a2f6f2a2aee8469b4.tar.gz
reply-6b50bdb6053ee46305ef761a2f6f2a2aee8469b4.zip
add some option parsing to the reply script
-rw-r--r--bin/reply25
1 files changed, 24 insertions, 1 deletions
diff --git a/bin/reply b/bin/reply
index f6f5171..c4f284c 100644
--- a/bin/reply
+++ b/bin/reply
@@ -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