From da6169816e772b5b07610d74d5c913631f2dc970 Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Mon, 14 Sep 2020 17:02:20 +0000
Subject: [PATCH] Bug 26459: Add hold-mode option to sip_cli_emulator

To test:
1 - Apply patch
2 - Restart all
3 - Place an item level hold for a patron via the staff client
4 - Cancel the hold using the sip_cli_emulator with hold-mode: -
perl misc/sip_cli_emulator.pl -a localhost -p 6001 -su term1 -sp term1 --patron {cardnumber} --item {BARCODE}  -m hold -l CPL --hold-mode -
5 - Run the sip_cli_emulator with no params
6 - Verify help text is understandable

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
---
 misc/sip_cli_emulator.pl | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/misc/sip_cli_emulator.pl b/misc/sip_cli_emulator.pl
index 5f4b326a26..657847fd59 100755
--- a/misc/sip_cli_emulator.pl
+++ b/misc/sip_cli_emulator.pl
@@ -53,6 +53,7 @@ my $fee_amount;
 my $fee_identifier;
 my $transaction_id;
 my $pickup_location;
+my $hold_mode;
 
 my $terminator = q{};
 
@@ -81,6 +82,7 @@ GetOptions(
     "fee-identifier=s"  => \$fee_identifier,
     "transaction-id=s"  => \$transaction_id,
     "pickup-location=s" => \$pickup_location,
+    "hold-mode=s"       => \$hold_mode,
 
     "t|terminator=s" => \$terminator,
 
@@ -264,7 +266,7 @@ my $handlers = {
         name       => 'Hold',
         subroutine => \&build_hold_command_message,
         parameters => {
-            hold_mode           => '+',
+            hold_mode           => $hold_mode eq '-' ? '-' : '+',
             transaction_date    => $transaction_date,
             expiration_date     => undef,
             pickup_location     => $pickup_location,
@@ -639,6 +641,7 @@ Options:
   --fee-identifier  Fee identifier for Fee Paid message, optional
   --transaction-id  Transaction id for Fee Paid message, optional
   --pickup-location Pickup location (branchcode) for Hold message, optional
+  --hold-mode       Accepts +: Add hold or -:cancel hold, defaults to +
 
   -m --message     SIP2 message to execute
 
-- 
2.31.0