Skip to content

Commit 3bba884

Browse files
committed
chore: Refactor runastyle scripts to support future runners (pipx, uvx)
This refactor introduces a dedicated `ASTYLE_VERSION` variable (formatted as `X.Y.Z`) and derives `ASTYLE_VERSION_STR` automatically. This separation makes it clearer where to update the required version and ensures consistency across platforms. The change simplifies maintenance and prepares the scripts for use with command runners such as `pipx` or `uvx`.
1 parent da16a44 commit 3bba884

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

runastyle

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
88

99
cd $SCRIPT_DIR
1010

11-
# If project management wishes to take a newer astyle version into use
12-
# just change this string to match the start of astyle version string.
13-
ASTYLE_VERSION="Artistic Style Version 3.0.1"
11+
# To require a newer astyle version, update ASTYLE_VERSION below.
12+
# ASTYLE_VERSION_STR is then constructed to match the beginning of the
13+
# version string reported by "astyle --version".
14+
ASTYLE_VERSION="3.0.1"
15+
ASTYLE_VERSION_STR="Artistic Style Version ${ASTYLE_VERSION}"
1416
ASTYLE="astyle"
1517

16-
DETECTED_VERSION=`$ASTYLE --version 2>&1`
17-
if [[ "$DETECTED_VERSION" != ${ASTYLE_VERSION}* ]]; then
18-
echo "You should use: ${ASTYLE_VERSION}";
19-
echo "Detected: ${DETECTED_VERSION}"
18+
DETECTED_VERSION_STR=`$ASTYLE --version 2>&1`
19+
if [[ "$DETECTED_VERSION_STR" != ${ASTYLE_VERSION_STR}* ]]; then
20+
echo "You should use: ${ASTYLE_VERSION_STR}";
21+
echo "Detected: ${DETECTED_VERSION_STR}"
2022
exit 1;
2123
fi
2224

runastyle.bat

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ SET SCRIPT_DIR=%~dp0
1010
@REM Change to that directory
1111
CD /d %SCRIPT_DIR%
1212

13-
@REM If project management wishes to take a newer astyle version into use
14-
@REM just change this string to match the start of astyle version string.
15-
@SET ASTYLE_VERSION="Artistic Style Version 3.0.1"
13+
@REM To require a newer astyle version, update ASTYLE_VERSION below.
14+
@REM ASTYLE_VERSION_STR is then constructed to match the beginning of the
15+
@REM version string reported by "astyle --version".
16+
@SET ASTYLE_VERSION="3.0.1"
17+
@SET ASTYLE_VERSION_STR="Artistic Style Version %ASTYLE_VERSION%"
1618
@SET ASTYLE="astyle"
1719

18-
@SET DETECTED_VERSION=""
19-
@FOR /F "tokens=*" %%i IN ('%ASTYLE% --version') DO SET DETECTED_VERSION=%%i
20-
@ECHO %DETECTED_VERSION% | FINDSTR /B /C:%ASTYLE_VERSION% > nul && (
21-
ECHO "%DETECTED_VERSION%" matches %ASTYLE_VERSION%
20+
@SET DETECTED_VERSION_STR=""
21+
@FOR /F "tokens=*" %%i IN ('%ASTYLE% --version') DO SET DETECTED_VERSION_STR=%%i
22+
@ECHO %DETECTED_VERSION_STR% | FINDSTR /B /C:%ASTYLE_VERSION_STR% > nul && (
23+
ECHO "%DETECTED_VERSION_STR%" matches %ASTYLE_VERSION_STR%
2224
) || (
23-
ECHO You should use: %ASTYLE_VERSION%
24-
ECHO Detected: "%DETECTED_VERSION%"
25+
ECHO You should use: %ASTYLE_VERSION_STR%
26+
ECHO Detected: "%DETECTED_VERSION_STR%"
2527
GOTO EXIT_ERROR
2628
)
2729

0 commit comments

Comments
 (0)