33# runformat - format this project's C++ sources with Uncrustify.
44#
55# Usage:
6- # ./runformat # format using the configured Uncrustify
7- # ./runformat --install # download, build, and use Uncrustify locally
6+ # ./runformat # format using the configured Uncrustify
7+ # ./runformat --install # download, build, and use Uncrustify locally
88# ./runformat --install --install-dir /abs/path
9+ # ./runformat --expected-uncrustify-version # print ONLY the expected Uncrustify version
910#
1011# You may also set:
1112# UNCRUSTIFY=/abs/path/to/uncrustify # use a specific binary
@@ -83,14 +84,21 @@ install_uncrustify() {
8384}
8485
8586print_usage_and_exit () {
86- sed -n ' 2,24p' " $0 " | sed ' s/^# \{0,1\}//'
87+ sed -n ' 2,25p' " $0 " | sed ' s/^# \{0,1\}//'
88+ exit 0
89+ }
90+
91+ # Print ONLY expected Uncrustify version (no extra text).
92+ print_expected_uncrustify_version_and_exit () {
93+ printf ' %s\n' " $UNCRUSTIFY_VERSION "
8794 exit 0
8895}
8996
9097# --------------------------
9198# Argument parsing
9299# --------------------------
93100DO_INSTALL=0
101+ PRINT_EXPECTED_UNCRUSTIFY_VERSION=0
94102# Accept: --install, --install-dir <dir>, -h/--help
95103while [[ $# -gt 0 ]]; do
96104 case " $1 " in
@@ -111,6 +119,10 @@ while [[ $# -gt 0 ]]; do
111119 fi
112120 shift 2
113121 ;;
122+ --expected-uncrustify-version)
123+ PRINT_EXPECTED_UNCRUSTIFY_VERSION=1
124+ shift
125+ ;;
114126 * )
115127 # ignore unrecognized positional args for now
116128 shift
@@ -124,6 +136,11 @@ if [[ "$DO_INSTALL" -eq 1 ]]; then
124136 UNCRUSTIFY=" $UNCRUSTIFY_BIN "
125137fi
126138
139+ # If requested, print ONLY the expected Uncrustify version and exit.
140+ if [[ " $PRINT_EXPECTED_UNCRUSTIFY_VERSION " -eq 1 ]]; then
141+ print_expected_uncrustify_version_and_exit
142+ fi
143+
127144# --------------------------
128145# Validate & run
129146# --------------------------
0 commit comments