Added new make.sh script

This commit is contained in:
Austen Adler 2017-01-08 01:09:25 -05:00
parent 17e9fda04e
commit c8f51182a6
No known key found for this signature in database
GPG Key ID: 7ECEE590CCDFE3F1

33
make.sh Executable file
View File

@ -0,0 +1,33 @@
if [ -z "$1" ]; then
echo "Usage:" >&2
echo "$0 lang > autoformat.sh" >&2
exit 1
fi
OPTS="${OPTS:---mode=$1}"
GLOB="${GLOB:-**/*.$1}"
# --style=google : google style (similar to 1tbs)
# -H : Pad header (space after if, for, while)
# -K : Indent cases
# -N : Indent namespaces
# -S : Indent switches
# -j : Always add brackets (even on one line if statements)
# -n : Don't make a backup
# -p : Pad operators
# -s2 : Two spaces
# -xG : Indent modifiers
# -xc : Brace attached to class names
# -xe : Erase blank lines
# -xl : Attach inlines
# -xn : Attach bracket to namespace
# -z2 : Force Linux lineending
BASE_OPTS='-H -K -N -S -j -n -p -s2 -xG -xc -xe -xl -xn -z2'
cat << EOF
#!/bin/zsh
# For support:
# https://austenwares.com/gogs/stonewareslord/autoformat/src/java
#
GLOB=( $GLOB )
OPTS=( $BASE_OPTS $OPTS )
astyle \$OPTS \$GLOB|\\grep -P '^(?!Unchanged)'||true
EOF