forked from danmar/simplecpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunastyle
More file actions
executable file
·37 lines (31 loc) · 1.18 KB
/
runastyle
File metadata and controls
executable file
·37 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# The version check in this script is used to avoid commit battles
# between different developers that use different astyle versions as
# different versions might have different output (this has happened in
# the past).
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd $SCRIPT_DIR
# To require a newer astyle version, update ASTYLE_VERSION below.
# ASTYLE_VERSION_STR is then constructed to match the beginning of the
# version string reported by "astyle --version".
ASTYLE_VERSION="3.4.13"
ASTYLE_VERSION_STR="Artistic Style Version ${ASTYLE_VERSION}"
ASTYLE="astyle"
if command -v astyle &> /dev/null; then
ASTYLE="astyle"
elif command -v uvx &> /dev/null; then
ASTYLE="uvx --quiet ${ASTYLE}==${ASTYLE_VERSION}"
elif command -v pipx &> /dev/null; then
ASTYLE="pipx run --quiet ${ASTYLE}==${ASTYLE_VERSION}"
else
echo "Neither astyle, uvx, nor pipx found in PATH"
exit 1
fi
DETECTED_VERSION_STR=`$ASTYLE --version 2>&1`
if [[ "$DETECTED_VERSION_STR" != ${ASTYLE_VERSION_STR}* ]]; then
echo "You should use: ${ASTYLE_VERSION_STR}";
echo "Detected: ${DETECTED_VERSION_STR}"
exit 1;
fi
# Run astyle with the project config
$ASTYLE --project *.h,*.cpp