[IMP] add argument validation with usage message
Add proper argument validation at the start of upgrade.sh: - Check that exactly 4 arguments are provided - Display a helpful usage message with argument descriptions - Include a concrete example command This prevents cryptic errors when the script is called incorrectly and provides clear guidance on expected parameters. With set -u enabled, accessing unset positional parameters would cause an unclear error message.
This commit is contained in:
25
upgrade.sh
25
upgrade.sh
@@ -1,6 +1,31 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
####################
|
||||
# USAGE & ARGUMENTS
|
||||
####################
|
||||
|
||||
usage() {
|
||||
cat <<EOF >&2
|
||||
Usage: $0 <origin_version> <final_version> <db_name> <service_name>
|
||||
|
||||
Arguments:
|
||||
origin_version Origin Odoo version number (e.g., 12 for version 12.0)
|
||||
final_version Target Odoo version number (e.g., 16 for version 16.0)
|
||||
db_name Name of the database to migrate
|
||||
service_name Name of the origin Odoo service (docker compose service)
|
||||
|
||||
Example:
|
||||
$0 14 16 elabore_20241208 odoo14
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ $# -lt 4 ]]; then
|
||||
echo "ERROR: Missing arguments. Expected 4, got $#." >&2
|
||||
usage
|
||||
fi
|
||||
|
||||
####################
|
||||
# GLOBAL VARIABLES #
|
||||
####################
|
||||
|
||||
Reference in New Issue
Block a user