mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
126 lines
3.0 KiB
Bash
Executable File
126 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
|
|
|
# Default: format all languages
|
|
FORMAT_JAVA=true
|
|
FORMAT_TS=true
|
|
FORMAT_CPP=true
|
|
FORMAT_CSHARP=true
|
|
FORMAT_HAXE=true
|
|
FORMAT_DART=true
|
|
FORMAT_SWIFT=true
|
|
|
|
# Parse command line arguments
|
|
show_help() {
|
|
echo "Spine Runtimes Code Formatter"
|
|
echo ""
|
|
echo "Usage: ./format.sh [options]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " --help, -h Show this help message"
|
|
echo " java Format only Java files"
|
|
echo " ts Format only TypeScript files"
|
|
echo " cpp Format only C/C++ files"
|
|
echo " csharp Format only C# files"
|
|
echo " haxe Format only Haxe files"
|
|
echo " dart Format only Dart files"
|
|
echo " swift Format only Swift files"
|
|
echo ""
|
|
echo "If no language flags are specified, all languages will be formatted."
|
|
echo "Multiple language flags can be combined, e.g.: ./format.sh java ts"
|
|
echo ""
|
|
echo "Tools used:"
|
|
echo " Java: Spotless with Eclipse formatter"
|
|
echo " TypeScript: tsfmt (typescript-formatter)"
|
|
echo " C/C++: clang-format"
|
|
echo " C#: dotnet format"
|
|
echo " Haxe: haxe formatter"
|
|
echo " Dart: dart format"
|
|
echo " Swift: swift-format"
|
|
exit 0
|
|
}
|
|
|
|
# If any language flags are specified, disable all by default
|
|
if [[ "$*" == *"java"* ]] || [[ "$*" == *"ts"* ]] || [[ "$*" == *"cpp"* ]] || [[ "$*" == *"csharp"* ]] || [[ "$*" == *"haxe"* ]] || [[ "$*" == *"dart"* ]] || [[ "$*" == *"swift"* ]]; then
|
|
FORMAT_JAVA=false
|
|
FORMAT_TS=false
|
|
FORMAT_CPP=false
|
|
FORMAT_CSHARP=false
|
|
FORMAT_HAXE=false
|
|
FORMAT_DART=false
|
|
FORMAT_SWIFT=false
|
|
fi
|
|
|
|
# Parse arguments
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--help|-h)
|
|
show_help
|
|
;;
|
|
java)
|
|
FORMAT_JAVA=true
|
|
shift
|
|
;;
|
|
ts)
|
|
FORMAT_TS=true
|
|
shift
|
|
;;
|
|
cpp)
|
|
FORMAT_CPP=true
|
|
shift
|
|
;;
|
|
csharp)
|
|
FORMAT_CSHARP=true
|
|
shift
|
|
;;
|
|
haxe)
|
|
FORMAT_HAXE=true
|
|
shift
|
|
;;
|
|
dart)
|
|
FORMAT_DART=true
|
|
shift
|
|
;;
|
|
swift)
|
|
FORMAT_SWIFT=true
|
|
shift
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1"
|
|
echo "Use --help for usage information"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Call individual formatter scripts
|
|
if [ "$FORMAT_CPP" = true ]; then
|
|
"$dir/format-cpp.sh"
|
|
fi
|
|
|
|
if [ "$FORMAT_JAVA" = true ]; then
|
|
"$dir/format-java.sh"
|
|
fi
|
|
|
|
if [ "$FORMAT_CSHARP" = true ]; then
|
|
"$dir/format-csharp.sh"
|
|
fi
|
|
|
|
if [ "$FORMAT_TS" = true ]; then
|
|
"$dir/format-ts.sh"
|
|
fi
|
|
|
|
if [ "$FORMAT_DART" = true ]; then
|
|
"$dir/format-dart.sh"
|
|
fi
|
|
|
|
if [ "$FORMAT_HAXE" = true ]; then
|
|
"$dir/format-haxe.sh"
|
|
fi
|
|
|
|
if [ "$FORMAT_SWIFT" = true ]; then
|
|
"$dir/format-swift.sh"
|
|
fi
|
|
|
|
echo "Formatting complete!" |