Skip to content

Commit cf69039

Browse files
authored
glossaire.sh: add force-tmx option, simplify logic (fixes #781) (#780)
1 parent ec05b8f commit cf69039

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

app/scripts/glossaire.sh

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,48 +39,53 @@ function echo_manual() {
3939
echo "---"
4040
echo "To update only one locale, and avoid creating a data snapshot at the end, add locale code and 'no-snapshot'"
4141
echo "(e.g. 'glossaire.sh fr no-snapshot' to update only French without creating a data snapshot)."
42+
echo "---"
43+
echo "To avoid pulling changes from repositories, add 'no-update'"
44+
echo "(e.g. 'glossaire.sh fr no-update' to update only French without updating repositories)."
45+
echo "---"
46+
echo "To force TMX creation, add 'force-tmx'"
47+
echo "(e.g. 'glossaire.sh force-tmx' to update all locales and forcing TMX creation)."
48+
echo "(e.g. 'glossaire.sh fr no-snapshot force-tmx' to update only French without creating a data snapshot and forcing TMX creation)."
4249
}
4350

4451
all_locales=true
4552
create_snapshot=true
53+
forceTMX=false
54+
checkrepo=true
4655

47-
if [ $# -eq 1 ]
48-
then
49-
# I have one parameter, it could be 'no-snapshot' or a locale code
50-
if [ "$1" == "help" ]
51-
then
52-
echo_manual
53-
exit 1
54-
elif [ "$1" == "no-snapshot" ]
55-
then
56-
create_snapshot=false
57-
else
58-
all_locales=false
59-
locale_code=$1
60-
fi
61-
fi
62-
63-
if [ $# -eq 2 ]
64-
then
65-
# I have two parameters, I expect the first to be a locale code, the
66-
# second to be 'no-snapshot'
67-
all_locales=false
68-
locale_code=$1
69-
if [ "$2" != "no-snapshot" ]
70-
then
71-
echo "ERROR: incorrect arguments."
72-
echo_manual
73-
exit 1
74-
fi
75-
create_snapshot=false
76-
fi
77-
78-
if [ $# -gt 2 ]
56+
while [[ $# -gt 0 ]]
57+
do
58+
case $1 in
59+
force-tmx)
60+
forceTMX=true
61+
;;
62+
help)
63+
echo_manual
64+
exit
65+
;;
66+
no-snapshot)
67+
create_snapshot=false
68+
;;
69+
no-update)
70+
checkrepo=false
71+
;;
72+
*)
73+
all_locales=false
74+
locale_code=$1
75+
;;
76+
esac
77+
shift
78+
done
79+
80+
echo "Request summary:"
81+
echo "* Create data snapshot: ${create_snapshot}"
82+
echo "* Force TMX creation: ${forceTMX}"
83+
echo "* Update repositories: ${checkrepo}"
84+
if [ "$all_locales" = true ]
7985
then
80-
# Too many parameters, warn and exit
81-
echo "ERROR: too many arguments."
82-
echo_manual
83-
exit 1
86+
echo "* Elaborate all locales: ${all_locales}"
87+
else
88+
echo "* Elaborate locale: ${locale_code}"
8489
fi
8590

8691
# Get configuration variables from config/config.ini
@@ -106,10 +111,6 @@ fi
106111
# Create all bash variables
107112
source $script_path/bash_variables.sh
108113

109-
# Set if we need to update repositories or force TMX creation
110-
checkrepo=true
111-
forceTMX=false
112-
113114
function updateLocale() {
114115
# Update this locale's repository
115116
# $1: Path to l10n repository

0 commit comments

Comments
 (0)