Skip to content

Commit 04cd05b

Browse files
committed
Tweak flags and output
1 parent 316c49c commit 04cd05b

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

scripts/check-i18n.sh

+15-8
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ Options:
5757
use as an argument to -c.
5858
5959
-n List/process only new localization pages, those without a '$I18N_DLC_KEY' key.
60-
-q Quiet mode. Do not list processed files.
61-
-v Enables verbose command progress and status output.
60+
-q Quiet mode. Do not list processed files. Prints summary unless -x is set.
61+
-v Verbose mode. List all processed files and their status.
6262
-x Return non-zero exit code if files were listed or hashes are missing.
6363
EOS
6464
}
@@ -91,6 +91,7 @@ function process_CLI_args() {
9191
q)
9292
FLAG_QUIET=1;;
9393
v)
94+
LIST_KIND="ALL"
9495
FLAG_VERBOSE=1;;
9596
x)
9697
FLAG_FAIL_ON_LIST_OR_MISSING=1;;
@@ -118,6 +119,11 @@ function process_CLI_args() {
118119
exit 1
119120
fi
120121

122+
if [[ $LIST_KIND == "ALL" && -n $FLAG_QUIET ]]; then
123+
echo -e "WARNING: -q flag ignored when -a or -v is used. For help use -h.\n"
124+
FLAG_QUIET=""
125+
fi
126+
121127
if [[ $LIST_KIND == "ALL" && -n $COMMIT_HASH_ARG ]]; then
122128
read -p "CAUTION! Set hash for all targets? (y/n): " response
123129
if [[ ! $response =~ ^[Yy] ]]; then
@@ -311,7 +317,9 @@ function main() {
311317
EN_VERSION=$(echo "$f" | sed "s/$DEFAULT_CONTENT\/.\{2,5\}\//$DEFAULT_CONTENT\/$DEFAULT_LANG\//g")
312318
if [[ ! -e "$EN_VERSION" ]]; then
313319
((FILE_PROCESSED_COUNT++))
314-
echo -e "File not found\t$EN_VERSION - $f - $DEFAULT_LANG was removed or renamed"
320+
if [[ -z $FLAG_QUIET ]]; then
321+
echo -e "File not found:\t$EN_VERSION - $f - $DEFAULT_LANG was removed or renamed"
322+
fi
315323
set_file_drifted_status "$f" "file not found"
316324
continue
317325
fi
@@ -323,9 +331,7 @@ function main() {
323331
if [ $DIFF_STATUS -gt 1 ]; then
324332
((FILE_PROCESSED_COUNT++))
325333
EXIT_STATUS=$DIFF_STATUS
326-
# if [[ -z $FLAG_QUIET ]]; then
327-
echo -e "HASH\tERROR\t$f: git diff error ($DIFF_STATUS) or invalid hash $LASTCOMMIT. For details, use -v."
328-
# fi
334+
echo -e "HASH\tERROR\t$f: git diff error ($DIFF_STATUS) or invalid hash $LASTCOMMIT. For details, use -v."
329335
if [[ -n $FLAG_VERBOSE ]]; then echo "$DIFF"; fi
330336
continue
331337
elif [[ -n "$DIFF" ]]; then
@@ -336,7 +342,8 @@ function main() {
336342
elif [[ -n $COMMIT_HASH_ARG ]]; then
337343
update_file_i18n_hash "$f" "$COMMIT_HASH_ARG" "$DIFF"
338344
elif [[ -z $FLAG_QUIET ]]; then
339-
echo "$DIFF - $f"
345+
echo -n "> Drifted file: $f"
346+
if [[ -n $FLAG_VERBOSE ]]; then echo "; diff summary: $DIFF"; else echo; fi
340347
fi
341348
elif [[ -z $LASTCOMMIT ]]; then
342349
((FILE_PROCESSED_COUNT++))
@@ -353,7 +360,7 @@ function main() {
353360
set_file_drifted_status "$f" $DRIFTED_STATUS
354361
done
355362

356-
if [[ -z $FLAG_QUIET ]]; then
363+
if [[ -z $FLAG_QUIET || $FLAG_FAIL_ON_LIST_OR_MISSING == 0 ]]; then
357364
echo "$LIST_KIND files: $FILE_PROCESSED_COUNT out of $FILE_COUNT"
358365
fi
359366

0 commit comments

Comments
 (0)