1#!/bin/bash 2 3function usage() { 4 echo "usage: $0 [--skip-if-empty] <gradle_arguments>" 5 echo 6 echo "Runs the ktfmt Gradle task with the provided gradle_arguments, if any of the files to check with .kt(s). Specify files to check using --file=<path> arguments." 7 echo 8 echo "--skip-if-empty: don't output a usage error if no arguments are provided" 9 exit 1 10} 11 12if [ "$1" == "" ]; then 13 usage 14fi 15 16if [ "$1" == "--skip-if-empty" ]; then 17 shift 18fi 19 20PROJECT_ROOT=$(dirname "$0")/.. 21 22 23if echo "$@" | tr ' ' '\n' | grep -q "^--file=.\+\.kts\?$"; then 24 exec "$PROJECT_ROOT"/gradlew -q -p "$PROJECT_ROOT" --continue :ktCheckFile --configuration-cache "$@" 25fi 26