diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-03 20:53:54 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-03 20:53:54 +0200 |
commit | b241b009646b36891e6b6c9d336357ed595d4dc7 (patch) | |
tree | 0a47390083f6994698bb71aa524e0642912e2ae1 /build/c/init | |
parent | feat(templates/latex/letter): Init (diff) | |
download | flake-templates-b241b009646b36891e6b6c9d336357ed595d4dc7.tar.gz flake-templates-b241b009646b36891e6b6c9d336357ed595d4dc7.zip |
chore(build): Regenerate
Diffstat (limited to '')
-rw-r--r-- | build/c/init | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/build/c/init b/build/c/init index edb0d1e..1ea1603 100644 --- a/build/c/init +++ b/build/c/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 |