File tree 1 file changed +18
-5
lines changed
1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,18 @@ cmake_formatting() {
102
102
fi
103
103
}
104
104
105
+ track_progress () {
106
+ local total=$1
107
+ local current=0
108
+
109
+ while IFS= read -r _; do
110
+ (( current++ )) || :
111
+ percent=$(( current * 100 / total))
112
+ printf ' \rProgress: [%-50s] %d%%' " $( printf ' #%.0s' $( seq 1 $(( percent / 2 )) ) ) " " $percent "
113
+ done
114
+ echo
115
+ }
116
+
105
117
cpp_formatting () {
106
118
echo " Formatting cpp files..."
107
119
@@ -112,11 +124,11 @@ cpp_formatting() {
112
124
tmpdir=$( mktemp -d)
113
125
trap ' rm -rf "$tmpdir"' EXIT
114
126
115
- printf ' %s\n' " ${files[@]} " | xargs -P " $( nproc) " -I{} bash -c "
127
+ printf ' %s\n' " ${files[@]} " | xargs --verbose - P " $( nproc) " -I{} bash -c "
116
128
mkdir -p \"\$ (dirname \" $tmpdir /{}\" )\"
117
- diff -u --color=always --label \" {}\" --label \" {}\" \" {}\" <(clang-format \" {}\" ) > \" $tmpdir /{}\"
129
+ diff -u --color=always --label \" {}\" --label \" {}\" \" {}\" <(clang-format \" {}\" ) > \" $tmpdir /{}\"
118
130
:
119
- "
131
+ " | & track_progress ${ # files[@]}
120
132
121
133
for file in " ${files[@]} " ; do
122
134
if [ -s " $tmpdir /$file " ]; then
@@ -125,7 +137,8 @@ cpp_formatting() {
125
137
fi
126
138
done
127
139
else
128
- printf ' %s\n' " ${files[@]} " | xargs -n1 -P " $( nproc) " clang-format -i
140
+ printf ' %s\n' " ${files[@]} " | xargs -n1 -P " $( nproc) " clang-format -i | &
141
+ track_progress ${# files[@]}
129
142
fi
130
143
}
131
144
@@ -167,8 +180,8 @@ sh_formatting() {
167
180
}
168
181
169
182
cmake_formatting
170
- cpp_formatting
171
183
yaml_json_formatting
172
184
sh_formatting
185
+ cpp_formatting
173
186
174
187
exit $exit_code
You can’t perform that action at this time.
0 commit comments