ghmerge: Unify behavior on error in CLI arguments and improve usage output
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Thu, 8 Oct 2020 11:02:29 +0000 (13:02 +0200)
committerPauli <paul.dale@oracle.com>
Mon, 16 Nov 2020 09:31:51 +0000 (19:31 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/72)

review-tools/ghmerge

index c309c7ab7b8e8ed331408a1b1c842a189cca44dd..c8f64dc72806a9bae53e65ba411a27941c1395b0 100755 (executable)
@@ -1,5 +1,12 @@
 #! /bin/bash
 
+function usage_exit {
+    echo "Usage: $0 <options including prnum and reviewer(s)>"
+    echo "    or $0 [<options>] -- <prnum> <reviewer>..."
+    echo "Options may include addrev options and gitaddrev filter args."
+    exit 9
+}
+
 set -o errexit
 
 WHAT=openssl
@@ -40,14 +47,14 @@ while [ $# -ne 0 ]; do
     --remote)
         if [ $# -lt 2 ] ; then
             echo "Missing argument of '$1'"
-            exit 1
+            usage_exit
         fi
         shift; REMOTE=$1; shift
         ;;
     --ref)
         if [ $# -lt 2 ] ; then
             echo "Missing argument of '$1'"
-            exit 1
+            usage_exit
         fi
         shift; REL=$1; shift
         ;;
@@ -92,8 +99,7 @@ if [ "$REMOTE" = "" ] ; then
 fi
 
 if [ "$PRNUM" = "" -o "$TEAM" = "" ] ; then
-    echo "Usage: $0 [flags, including addrev options] prnum reviewer..."
-    exit 1
+    usage_exit
 fi
 
 PR_URL=https://api.github.com/repos/openssl/$WHAT/pulls/$PRNUM