|
@ -8,11 +8,13 @@ |
|
|
# bcs.sh -C 10 new Vector3 |
|
|
# bcs.sh -C 10 new Vector3 |
|
|
# bcs.sh -x py sprite |
|
|
# bcs.sh -x py sprite |
|
|
# bcs.sh -i -x cs -f World spritebatch |
|
|
# 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 |
|
|
# https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash |
|
|
POSITIONAL=() |
|
|
POSITIONAL=() |
|
|
GREP_FLAGS="" |
|
|
GREP_FLAGS="" |
|
|
CONTEXT=3 |
|
|
CONTEXT=3 |
|
|
|
|
|
TREE=master |
|
|
|
|
|
|
|
|
while [[ $# -gt 0 ]] |
|
|
while [[ $# -gt 0 ]] |
|
|
do |
|
|
do |
|
@ -38,6 +40,11 @@ case $key in |
|
|
shift # past argument |
|
|
shift # past argument |
|
|
shift # past value |
|
|
shift # past value |
|
|
;; |
|
|
;; |
|
|
|
|
|
-t|--tree) |
|
|
|
|
|
TREE="$2" |
|
|
|
|
|
shift # past argument |
|
|
|
|
|
shift # past value |
|
|
|
|
|
;; |
|
|
*) # unknown option |
|
|
*) # unknown option |
|
|
POSITIONAL+=("$1") # save it in an array for later |
|
|
POSITIONAL+=("$1") # save it in an array for later |
|
|
shift # past argument |
|
|
shift # past argument |
|
@ -47,7 +54,7 @@ done |
|
|
set -- "${POSITIONAL[@]}" # restore positional parameters |
|
|
set -- "${POSITIONAL[@]}" # restore positional parameters |
|
|
|
|
|
|
|
|
if [[ -z $@ ]]; then |
|
|
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 |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
@ -60,7 +67,7 @@ if [[ -n $EXTENSION ]]; then |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if [[ -n $FILE ]]; then |
|
|
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 |
|
|
if [[ -z $files ]]; then |
|
|
echo "no files matched" |
|
|
echo "no files matched" |
|
|
exit 0 |
|
|
exit 0 |
|
|