Skip to content

Commit 03cd23a

Browse files
committed
Allow selective formatting
1 parent d6c29a6 commit 03cd23a

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

extras/formatting.sh

+31-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,33 @@ source_dir="$(dirname "$script_dir")"
77

88
check_only=0
99
no_version_check=0
10+
run_cpp=0
11+
run_yaml=0
12+
run_sh=0
13+
run_cmake=0
14+
run_all=1
1015

1116
while [[ "$#" -gt 0 ]]; do
1217
case $1 in
1318
-h | --help) help=1 ;;
1419
--check-only) check_only=1 ;;
1520
--no-version-check) no_version_check=1 ;;
21+
--cpp)
22+
run_cpp=1
23+
run_all=0
24+
;;
25+
--yaml)
26+
run_yaml=1
27+
run_all=0
28+
;;
29+
--sh)
30+
run_sh=1
31+
run_all=0
32+
;;
33+
--cmake)
34+
run_cmake=1
35+
run_all=0
36+
;;
1637
--source)
1738
source_dir="$2"
1839
shift
@@ -26,12 +47,16 @@ if [ "$help" ]; then
2647
cat <<EOF
2748
$me: Format or check formatting of files in this repo
2849
29-
Usage: $me [--check-only] [--no-version-check] [--source <path>]
50+
Usage: $me [--check-only] [--no-version-check] [--source <path>] [--cpp] [--yaml] [--sh] [--cmake]
3051
3152
Options:
3253
--check-only Check formatting without modifying files
3354
--no-version-check Skip version compatibility checks
34-
--source Path to source directory to format (defaults to parent of script directory)
55+
--source Path to source directory to format (defaults to parent of script directory)
56+
--cpp Format only C++ files
57+
--yaml Format only YAML/JSON files
58+
--sh Format only shell script files
59+
--cmake Format only CMake files
3560
EOF
3661
exit 0
3762
fi
@@ -166,9 +191,9 @@ sh_formatting() {
166191
fi
167192
}
168193

169-
cmake_formatting
170-
cpp_formatting
171-
yaml_json_formatting
172-
sh_formatting
194+
((run_all || run_cmake)) && cmake_formatting
195+
((run_all || run_cpp)) && cpp_formatting
196+
((run_all || run_yaml)) && yaml_json_formatting
197+
((run_all || run_sh)) && sh_formatting
173198

174199
exit $exit_code

0 commit comments

Comments
 (0)