@@ -3,19 +3,38 @@ set +a -u -o pipefail
3
3
4
4
if [[ " ${TRACE-0} " == " 1" ]]; then set -o xtrace; fi
5
5
6
- # Check crates, js packages, and openapi changes against `origin/main` and update their version.
7
- # At the end of the script, the commit message to used is displayed.
6
+ display_help () {
7
+ echo " Check crates, js packages, and openapi changes against 'origin/main' and update their versions"
8
+ echo
9
+ echo " By default, no changes are made (dry-run mode), use '--run' to apply the changes."
10
+ echo " At the end of the script, the commit message to used is displayed, use '--commit' to commit the changes."
11
+ echo
12
+ echo " Usage: $0 [OPTIONS]"
13
+ echo
14
+ echo " Options:"
15
+ echo " --run: to apply the changes (default is dry-run)"
16
+ echo " --commit: to commit the changes"
17
+ echo
18
+ echo " Prerequisites:"
19
+ echo " 'cargo-get' needs to be installed ('cargo install cargo-get')."
20
+ echo
21
+ exit 0;
22
+ }
8
23
9
- # Usage:
10
- # update_crate_versions.sh --run: to execute the changes (default is dry-run)
11
- # update_crate_versions.sh: to display the changes without executing them (dry-run mode)
24
+ check_requirements () {
25
+ cargo get --version 2> /dev/null 1> /dev/null ||
26
+ error " It seems 'cargo-get' is not installed or not in the path (to install run: 'cargo install cargo-get')." ;
27
+ }
12
28
13
- # Prerequisites:
14
- # `cargo-get` needs to be installed (`cargo install cargo-get`).
29
+ error () {
30
+ echo " ERROR: $1 " ;
31
+ exit 1;
32
+ }
15
33
16
34
# NOTE
17
35
# `cargo get workspace.members` display the list of path to crates in the workspace.
18
36
# for the `cargo set-version` command, we need the name of the module (last element of the path).
37
+
19
38
readonly ORANGE=" \e[1;33m"
20
39
readonly GREEN=" \e[1;32m"
21
40
readonly RESET=" \e[0m"
@@ -123,11 +142,14 @@ update_openapi_version() {
123
142
}
124
143
125
144
# ###############
145
+ check_requirements
146
+
126
147
declare DRY_RUN=true
127
148
declare COMMIT=false
128
149
readonly COMMIT_REF=" HEAD"
129
150
while [[ " $# " -gt 0 ]]; do
130
151
case $1 in
152
+ -h|--help) display_help ;;
131
153
--run) DRY_RUN=false ;;
132
154
--commit) COMMIT=true ;;
133
155
esac
0 commit comments