shithub: orca

Download patch

ref: 2ad1d13a571f278d9402dbd5f1da67530cab6432
parent: 17017e265221aec50004e1f853dd04687d21661b
author: cancel <cancel@cancel.fm>
date: Thu Nov 29 11:53:12 EST 2018

Add '--help' long opt to tool

--- a/tool
+++ b/tool
@@ -13,12 +13,12 @@
 
 print_usage() {
 cat <<EOF
-Usage: tool [options] <command> [<args>]
+Usage: tool [options] command [args]
 Options:
-    -v        Print important commands as they're executed.
-    -c <name> Use a specific compiler binary instead.
-              Default: \$CC, or cc
-    -h        Print this message and exit.
+    -v            Print important commands as they're executed.
+    -c <name>     Use a specific compiler binary instead.
+                  Default: \$CC, or cc
+    -h or --help  Print this message and exit.
 EOF
 }
 
@@ -26,8 +26,18 @@
 
 verbose=0
 
-while getopts c:hv- opt_val; do
+while getopts c:hv-: opt_val; do
   case "$opt_val" in
+    -)
+      case "$OPTARG" in
+        help) print_usage; exit 0;;
+        *)
+          echo "Unknown long option --$OPTARG" >&2
+          print_usage >&2
+          exit 1
+          ;;
+      esac
+      ;;
     c) compiler_exe="$OPTARG";;
     v) verbose=1;;
     h) print_usage; exit 0;;