From 7685bfc61ab2537dbb46ec2aed299d0142d8c0f3 Mon Sep 17 00:00:00 2001
From: "Bradley M. Kuhn" <bkuhn@ebb.org>
Date: Sun, 15 Jul 2018 09:05:33 -0700
Subject: [PATCH] More command line options.

---
 scripts/rt-outreachy-payment-next.plx | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/scripts/rt-outreachy-payment-next.plx b/scripts/rt-outreachy-payment-next.plx
index 601e0fa..5296ee0 100755
--- a/scripts/rt-outreachy-payment-next.plx
+++ b/scripts/rt-outreachy-payment-next.plx
@@ -11,9 +11,11 @@ use Getopt::Long;
 use File::Spec;
 use Date::Manip qw(ParseDate UnixDate);
 
+my($PAYMENT_DIR, $VERBOSE, $INTERACTIVE, $PAYMENT_NUMBER, $RT_CMD);
+
 sub FindUniqueTicket(@) {
   my @searchTerms = @_;
-  open(my $rtLsFH, "-|", "rt", "ls", "-i", 'Queue = outreachy-interns AND ' .
+  open(my $rtLsFH, "-|", "$RT_CMD", "ls", "-i", 'Queue = outreachy-interns AND ' .
        join(" AND ", @searchTerms));
   my $ticketSpec;
   while (my $lsLine = <$rtLsFH>) {
@@ -29,14 +31,22 @@ sub FindUniqueTicket(@) {
   close $rtLsFH;
   return $ticketSpec;
 }
-my($PAYMENT_DIR, $VERBOSE);
 
-GetOptions("paymentDir=s", \$PAYMENT_DIR, "verbose=i", \$VERBOSE);
+GetOptions("paymentDir=s" => \$PAYMENT_DIR, "verbose=i" => \$VERBOSE, "interactive" => \$INTERACTIVE,
+           "paymentNumber=i" => \$PAYMENT_NUMBER, "rtCommand=s" => $RT_CMD);
+
+$RT_CMD = '/usr/bin/rt' unless defined $RT_CMD;
+
+$INTERACTIVE = 0 if not defined $INTERACTIVE;
 
 unless (defined $PAYMENT_DIR and -d $PAYMENT_DIR) {
   print STDERR "usage: $0 --paymentDir=<DIRECTORY>   option is required and directory must exist\n";
   exit 1;
 }
+unless (defined $PAYMENT_NUMBER and $PAYMENT_NUMBER =~ /^123$/) {
+  print STDERR "usage: $0 --paymentNumber=<VALUE>  option is required and must be 1, 2 or 3\n";
+  exit 1;
+}
 $VERBOSE = 0 unless defined $VERBOSE;
 
 opendir(my $dh, $PAYMENT_DIR);