@@ -3,19 +3,38 @@ set +a -u -o pipefail
33
44if [[ " ${TRACE-0} " == " 1" ]]; then set -o xtrace; fi
55
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 version"
8+ echo
9+ echo " By default, no changes are made (dry-run mode), use '--run' to execute 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 execute 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+ }
823
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+ }
1228
13- # Prerequisites:
14- # `cargo-get` needs to be installed (`cargo install cargo-get`).
29+ error () {
30+ echo " ERROR: $1 " ;
31+ exit 1;
32+ }
1533
1634# NOTE
1735# `cargo get workspace.members` display the list of path to crates in the workspace.
1836# for the `cargo set-version` command, we need the name of the module (last element of the path).
37+
1938readonly ORANGE=" \e[1;33m"
2039readonly GREEN=" \e[1;32m"
2140readonly RESET=" \e[0m"
@@ -123,11 +142,14 @@ update_openapi_version() {
123142}
124143
125144# ###############
145+ check_requirements
146+
126147declare DRY_RUN=true
127148declare COMMIT=false
128149readonly COMMIT_REF=" HEAD"
129150while [[ " $# " -gt 0 ]]; do
130151 case $1 in
152+ -h|--help) display_help ;;
131153 --run) DRY_RUN=false ;;
132154 --commit) COMMIT=true ;;
133155 esac
0 commit comments