From e7f15bb94e500bebebc484b738d79c97ec4a2b3e Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Fri, 14 Feb 2020 00:06:11 -0500 Subject: [PATCH] bcs: allow names of other tree-likes, such as MonoGame's 'develop' branch GitOrigin-RevId: b7fc8ac5aa313168e5cfdc1a82e4931bb617d4b5 --- tools/scripts/bcs.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/scripts/bcs.sh b/tools/scripts/bcs.sh index 276cc02..05d1662 100644 --- a/tools/scripts/bcs.sh +++ b/tools/scripts/bcs.sh @@ -8,11 +8,13 @@ # bcs.sh -C 10 new Vector3 # bcs.sh -x py sprite # bcs.sh -i -x cs -f World spritebatch +# bcs.sh --tree develop -x cs -f MonoGame.Framework SpriteBatch # https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash POSITIONAL=() GREP_FLAGS="" CONTEXT=3 +TREE=master while [[ $# -gt 0 ]] do @@ -38,6 +40,11 @@ case $key in shift # past argument shift # past value ;; + -t|--tree) + TREE="$2" + shift # past argument + shift # past value + ;; *) # unknown option POSITIONAL+=("$1") # save it in an array for later shift # past argument @@ -47,7 +54,7 @@ done set -- "${POSITIONAL[@]}" # restore positional parameters if [[ -z $@ ]]; then - echo 'Usage: bcs.sh [-i] [-f/--file FILE_PATTERN] [-x/--extension EXTENSION] [-C/--context NUM_LINES] QUERY' + echo 'Usage: bcs.sh [-i] [-f/--file FILE_PATTERN] [-x/--extension EXTENSION] [-C/--context NUM_LINES] [-t/--tree TREE_NAME] QUERY' exit 1 fi @@ -60,7 +67,7 @@ if [[ -n $EXTENSION ]]; then fi if [[ -n $FILE ]]; then - files=$(git ls-tree -r master --name-only | grep "${FILE}") + files=$(git ls-tree -r ${TREE} --name-only | grep "${FILE}") if [[ -z $files ]]; then echo "no files matched" exit 0