about summary refs log tree commit diff stats
path: root/build/latex/academia/init
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--build/latex/academia/init32
-rwxr-xr-xbuild/latex/academia/init.local28
2 files changed, 55 insertions, 5 deletions
diff --git a/build/latex/academia/init b/build/latex/academia/init
index edb0d1e..1ea1603 100644
--- a/build/latex/academia/init
+++ b/build/latex/academia/init
@@ -14,6 +14,13 @@ remove_self() {
     rm "$(realpath "$0")"
     rm "$(realpath "$(dirname "$0")")/shell_line_editor.sh"
 }
+require() {
+    program="$1"
+    if ! command -v "$program" >/dev/null; then
+        echo "Please install '$program' for this init script to work." 1>&2
+        exit 1
+    fi
+}
 
 # Prompt the user for a specific variable.
 # ## Args:
@@ -47,11 +54,21 @@ prompt() {
     printf "%s\n" "$pr_new_variable" >>"$replacement_file"
 }
 
+require git
+
+require jq
+require curl
+
+require fd
+require mv
+require sed
+require chmod
+
 git init
 
 # necessary meta data
 prompt APPLICATION_NAME "The name of the application" "$(basename "$PWD")"
-prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" sed 's/[_-]/ /g' | sed 's/^\(\w\)/\U\1/g' | sed 's/ \(\w\)/ \U\1/g')"
+prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/[_-]/ /g' | sed 's/^\(\w\)/\U\1/g' | sed 's/ \(\w\)/ \U\1/g')"
 prompt APPLICATION_NAME_CAPITALIZED_MAN_PART "The capitalized name of the application (for documentation also with a man section part)" "$(echo "$APPLICATION_NAME" | sed 's/_/-/g' | sed 's/\(.*\)/\U\1(1)/')" "dont_ask"
 prompt APPLICATION_VERSION "The version of this program, without the prefix" "0.1.0"
 
@@ -77,7 +94,7 @@ if [ -e ./lpm.toml ]; then
 else
     init_default_license="AGPL-3.0-or-later"
 fi
-prompt SPDX_LICENSE_IDENTIFIER "THE SPDX identifer of your choosen license" "$init_default_license" "dont_ask"
+prompt SPDX_LICENSE_IDENTIFIER "THE SPDX identifer of your choosen license" "$init_default_license"
 
 default_license_url="$(curl --silent --show-error "https://spdx.org/licenses/$SPDX_LICENSE_IDENTIFIER.json" | jq --raw-output '.seeAlso[0]')"
 
@@ -86,8 +103,9 @@ if curl --fail --silent --show-error "$default_license_url.txt" >/dev/null; then
     default_license_url="$default_license_url.txt"
 fi
 prompt LICENSE_URL "The url of the license" "$default_license_url"
-prompt REUSE_TEMPLATE "The template used in reuse annotate" "$(
-    cat <<EOF | fmt --uniform-spacing --width=75
+
+if [ -e ./.reuse/templates/default.jinja2 ]; then
+    cat <<EOF | fmt --uniform-spacing --width=75 >./.reuse/templates/default.jinja2
 {% for copyright_line in copyright_lines %}
 {{ copyright_line }}
 {% endfor %}
@@ -102,8 +120,12 @@ This file is part of $APPLICATION_NAME_STYLIZED - $DESCRIPTION.
 
 You should have received a copy of the License along with this program.
 If not, see <$LICENSE_URL>.
+<!-- vim: ft=htmldjango -->
 EOF
-)" "dont_ask"
+fi
+
+# Allow templates to add template specific prompts
+[ -e init.local ] && . ./init.local
 
 echo "$DESCRIPTION" >.git/description
 
diff --git a/build/latex/academia/init.local b/build/latex/academia/init.local
new file mode 100755
index 0000000..ae57756
--- /dev/null
+++ b/build/latex/academia/init.local
@@ -0,0 +1,28 @@
+#!/usr/bin/env sh
+
+prompt LANGUAGE "The language to use in the latex documents" "en_GB"
+
+bable_language=""
+case "$LANGUAGE" in
+"en_GB")
+    bable_language="british"
+    ;;
+en_*)
+    bable_language="english"
+    ;;
+de_DE | de_*)
+    bable_language="ngerman"
+    ;;
+
+*)
+    echo "'$LANGUAGE' is not yet recognized by the init.local script! Please open an issue." 1>&2
+    echo "set 'BABLE_LANGUAGE' to 'NOT_YET_RECOGNIZED_PLEASE_REPLACE' to help you find instances of the variable use." 1>&2
+    bable_language="NOT_YET_RECOGNIZED_PLEASE_REPLACE"
+    ;;
+esac
+
+prompt BABLE_LANGUAGE "The language to use for the bable package" "$bable_language" "dont_ask"
+prompt DATE_TIME_LANGUAGE "The language to use for the datetime2 package" "$(echo "$LANGUAGE" | sed 's/_/-/g')" "dont_ask"
+prompt SIUNITX_LANGUAGE "The language to use for the siunitx package" "$(echo "$LANGUAGE" | sed 's/\(\w\w\).*/\U\1/')" "dont_ask"
+
+# vim: ft=sh