diff options
Diffstat (limited to 'build/latex/academia/init')
-rw-r--r-- | build/latex/academia/init | 32 |
1 files changed, 27 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 |