From 1cafda619a6b4ba72634e6f80d116ee3488f62c4 Mon Sep 17 00:00:00 2001
From: Maximilian Moser <maximilian.moser@tuwien.ac.at>
Date: Wed, 5 Feb 2025 10:35:15 +0100
Subject: [PATCH] Update babel.sh

* forward extra arguments to pybabel
* add missing fixed argument to "extract"
* provide better usage information
---
 babel.sh                                 | 32 ++++++++++++++++++------
 invenio_config_tuw/translations/.gitkeep |  0
 2 files changed, 24 insertions(+), 8 deletions(-)
 create mode 100644 invenio_config_tuw/translations/.gitkeep

diff --git a/babel.sh b/babel.sh
index a1dec61..71998ad 100755
--- a/babel.sh
+++ b/babel.sh
@@ -1,24 +1,35 @@
 #!/bin/bash
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2024 TU Wien.
+# Copyright (C) 2024-2025 TU Wien.
 #
 # Invenio-Config-TUW is free software; you can redistribute it and/or modify
 # it under the terms of the MIT License; see LICENSE file for more details.
 
+function usage() {
+    echo "usage: ${0} <COMMAND> [args...]"
+    echo
+    echo "available commands: compile, extract, init, update"
+}
+
 if [[ $# -lt 1 ]]; then
-    echo >&2 "error: expected at least one argument"
+    usage >&2
+    exit 1
 fi
 
-case "${1}" in
+command="${1}"
+shift
+case "${command}" in
     init)
         pybabel init \
             --input-file "invenio_config_tuw/translations/messages.pot" \
-            --output-dir "invenio_config_tuw/translations/"
+            --output-dir "invenio_config_tuw/translations/" \
+            "${@}"
         ;;
     compile)
         pybabel compile \
-            --directory "invenio_config_tuw/translations/"
+            --directory "invenio_config_tuw/translations/" \
+            "${@}"
         ;;
     extract)
         pybabel extract \
@@ -26,15 +37,20 @@ case "${1}" in
             --msgid-bugs-address "tudata@tuwien.ac.at" \
             --mapping-file "babel.ini" \
             --output-file "invenio_config_tuw/translations/messages.pot" \
-            --add-comments "NOTE"
+            --add-comments "NOTE" \
+            invenio_config_tuw \
+            "${@}"
         ;;
     update)
         pybabel update \
             --input-file "invenio_config_tuw/translations/messages.pot" \
-            --output-dir "invenio_config_tuw/translations/"
+            --output-dir "invenio_config_tuw/translations/" \
+            "${@}"
         ;;
     *)
-        echo >&2 "unknown command: ${1}"
+        echo >&2 "error: unknown command: ${command}"
+        echo >&2
+        usage >&2
         exit 1
         ;;
 esac
diff --git a/invenio_config_tuw/translations/.gitkeep b/invenio_config_tuw/translations/.gitkeep
new file mode 100644
index 0000000..e69de29
-- 
GitLab