Browse Source

fix: minor args parsing improvements

Kyle P Davis 6 months ago
parent
commit
1afede0060
1 changed files with 11 additions and 6 deletions
  1. 11 6
      gimme

+ 11 - 6
gimme

@@ -173,6 +173,14 @@ else # normal usage
 	DID_GIMME=
 	for GIMME; do
 
+		if [[ "$GIMME" =~ --?h(elp)? ]]; then
+			sed -n -e'/^#[[:space:]]/p' -e'/^###/q' "$0" | sed -e's/^# //'
+			echo "GIMMES:"
+			cd "$GIMME_GIMMES_DIR"
+            find . -type f -perm +1 | sed -e's/^..//' -e'/^_/d' -e's/^/    /' | sort
+			exit 0
+		fi
+
 		case "$GIMME" in
 			-v|--verbose|--debug)
 				DEBUG=1
@@ -187,12 +195,6 @@ else # normal usage
 				git log -1
 				exit 0
 				;;
-			-h|--help|"")
-				sed -n -e'/^#[[:space:]]/p' -e'/^###/q' "$0"
-				echo "# GIMMES:"
-				echo $(cd "$GIMME_GIMMES_DIR"; find . -type f -perm +1 | sed -e's/^..//' -e'/^_/d' | sort)
-				exit 0
-				;;
 			-l|--list|--installed)
 				echo "# BREW:"
 				brew list
@@ -215,6 +217,9 @@ else # normal usage
 				pip list --format=columns --outdated
 				exit 0
 				;;
+            --)
+                exit 0
+                ;;
 			-*)
 				echo "# ERROR: Unknown option: $GIMME"
 				continue