diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-04-02 14:26:11 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-04-02 14:26:11 +0200 |
commit | aabba688f54323f1cd4451ec068598152b67d9e0 (patch) | |
tree | b733baef48cd1b3bee997f73b6d5d181f4da1e84 /templates | |
parent | chore(common/treefmt.nix): Ignore the pre-generation markdown file (diff) | |
download | flake-templates-aabba688f54323f1cd4451ec068598152b67d9e0.tar.gz flake-templates-aabba688f54323f1cd4451ec068598152b67d9e0.zip |
chore(templates): Update common files
Diffstat (limited to 'templates')
-rw-r--r-- | templates/awk/.licensure.yml | 14 | ||||
-rw-r--r-- | templates/awk/docs/%INIT_APPLICATION_NAME.1.md | 54 | ||||
-rw-r--r-- | templates/awk/docs/TODO.1.md | 70 | ||||
-rwxr-xr-x | templates/awk/init | 53 | ||||
-rw-r--r-- | templates/awk/treefmt.nix | 1 | ||||
-rw-r--r-- | templates/c/.licensure.yml | 14 | ||||
-rw-r--r-- | templates/c/docs/%INIT_APPLICATION_NAME.1.md | 54 | ||||
-rw-r--r-- | templates/c/docs/TODO.1.md | 70 | ||||
-rwxr-xr-x | templates/c/init | 53 | ||||
-rw-r--r-- | templates/c/treefmt.nix | 1 | ||||
-rw-r--r-- | templates/latex/.licensure.yml | 14 | ||||
-rwxr-xr-x | templates/latex/init | 53 | ||||
-rw-r--r-- | templates/latex/treefmt.nix | 1 | ||||
-rw-r--r-- | templates/rust/.licensure.yml | 14 | ||||
-rw-r--r-- | templates/rust/docs/%INIT_APPLICATION_NAME.1.md | 54 | ||||
-rw-r--r-- | templates/rust/docs/TODO.1.md | 70 | ||||
-rwxr-xr-x | templates/rust/init | 53 | ||||
-rw-r--r-- | templates/rust/treefmt.nix | 1 | ||||
-rw-r--r-- | templates/shell/.licensure.yml | 14 | ||||
-rw-r--r-- | templates/shell/docs/%INIT_APPLICATION_NAME.1.md | 54 | ||||
-rw-r--r-- | templates/shell/docs/TODO.1.md | 70 | ||||
-rwxr-xr-x | templates/shell/init | 53 | ||||
-rw-r--r-- | templates/shell/treefmt.nix | 1 |
23 files changed, 451 insertions, 385 deletions
diff --git a/templates/awk/.licensure.yml b/templates/awk/.licensure.yml index 942a96f..60ef45c 100644 --- a/templates/awk/.licensure.yml +++ b/templates/awk/.licensure.yml @@ -22,10 +22,10 @@ licenses: email: "%INIT_AUTHOR_EMAIL" template: | - TODO 2024 - [year] (C) by [name of author] + %INIT_APPLIACATION_NAME_STYLIZED %INIT_YEAR - [year] (C) by [name of author] SPDX-License-Identifier: CC-BY-SA-4.0 - TODO is licensed under a + %INIT_APPLIACATION_NAME_STYLIZED is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. You should have received a copy of the license along with this @@ -51,9 +51,9 @@ licenses: # A list of authors who hold copyright over these files authors: # Provide either your full name or company name for copyright purposes - - name: Benedikt Peetz + - name: "%INIT_AUTHOR_NAME" # Optionally provide email for copyright purposes - email: "benedikt.peetz@b-peetz.de" + email: "%INIT_AUTHOR_EMAIL" # The template that will be rendered to generate the header before # comment characters are applied. Available variables are: @@ -63,13 +63,13 @@ licenses: # Name <email@example.com>. If multiple authors are provided the # list is concatenated together with commas. template: | - Copyright (C) 2023 - [year]: + Copyright (C) %INIT_YEAR - [year]: [name of author] SPDX-License-Identifier: GPL-3.0-or-later - This file is part of the TODO. + This file is part of %INIT_APPLICATION_NAME_STYLIZED. - TODO is free software: you can redistribute it and/or modify + %INIT_APPLICATION_NAME_STYLIZED is free software: you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/templates/awk/docs/%INIT_APPLICATION_NAME.1.md b/templates/awk/docs/%INIT_APPLICATION_NAME.1.md new file mode 100644 index 0000000..0a7ec9d --- /dev/null +++ b/templates/awk/docs/%INIT_APPLICATION_NAME.1.md @@ -0,0 +1,54 @@ +% %INIT_APPLICATION_NAME_CAPITALIZED_MAN_PART %INIT_APPLICATION_NAME %INIT_APPLICATION_VERSION +% %INIT_AUTHOR_NAME +% %INIT_CURRENT_DATE + +# NAME + +%INIT_APPLICATION_NAME - %INIT_DESCRIPTION + +# SYNOPSIS + +**%INIT_APPLICATION_NAME** \[*--help*|*--version*\] + +# DESCRIPTION + +TODO + +# OPTIONS + +**--help**, **-h** +: Displays a help message and exit. + +**--version**, **-v** +: Displays the software version and exit. + +# EXAMPLES + +**%INIT_APPLICATION_NAME** +: TODO. See the Description section for further details. + +# FILES + +*name.file* +: This file is important because it does x. + +# BUGS + +Report bugs to <https://%INIT_REMOTE/%INIT_OWNER/%INIT_REPOSITORY/issues>. + +# COPYRIGHT + +Copyright (C) %INIT_YEAR %INIT_AUTOHR_NAME + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/templates/awk/docs/TODO.1.md b/templates/awk/docs/TODO.1.md deleted file mode 100644 index e14fec5..0000000 --- a/templates/awk/docs/TODO.1.md +++ /dev/null @@ -1,70 +0,0 @@ -% FUPDATE(1) fupdate 1.0.0 -% Benedikt Peetz -% May 2023 - -# NAME - -fupdate - updates your flake, while checking for common mistakes - -# SYNOPSIS - -**fupdate** list of \[*flake*|*\<some word>*|*--help*|*-h*\] - -# DESCRIPTION - -Argument can be stacked, this makes it possible to specify multiple targets to be updated in succession. See the Examples section for further details. - -No argument or *flake* -: **fupdate**, when executed without arguments or with *flake*, will update your *flake.lock*, check for duplicate flake inputs, i.e., an input has an input declared, which you have also declared as input, and will run a script called *update.sh*, if you allow it. -The allowance for the script is asked, when you run **fupdate** and the found script is not yet allowed. Furthermore, the allowance is based on the concrete sha256 hash of the script, so any changes will require another allowance. - -**\<some word>** as argument -: If the executable **update-\<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit. - -# OPTIONS - -**--help**, **-h** -: Displays a help message and exit. - -**--version**, **-v** -: Displays the software version and exit. - -# EXAMPLES - -**fupdate** or **fupdate flake** -: Updates your *flake.lock*. See the Description section for further details. - -**fupdate sys** -: Run the executable **update-sys**, if it exists. See the Description section for further details. - -**fupdate flake sys docs** -: First updates your flake, then, if the command succeeded, runs **update-sys**, afterweich **update-docs** is run. - -# FILES - -*update.sh* -: This is supposed to be a shell script located in your flake base directory, i.e., the directory which contains both a *flake.nix* and a *flake.lock* file. - -*~/.local/share/flake-update/* -: **fupdate** will store the hashes to the allowed *update.sh* files here. - -# BUGS - -Report bugs to <https://codeberg.org/soispha/flake_update/issues>. - -# COPYRIGHT - -Copyright (C) 2023 Benedikt Peetz - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/templates/awk/init b/templates/awk/init index 787b663..df0b4c5 100755 --- a/templates/awk/init +++ b/templates/awk/init @@ -5,34 +5,41 @@ replacement_file="$(mktemp)" trap cleanup INT -trap "cleanup; remove" EXIT +trap "cleanup; remove_self" EXIT cleanup() { rm "$replacement_file" } -remove() { +remove_self() { rm "$(realpath "$0")" rm "$(realpath "$(dirname "$0")")/shell_line_editor.sh" - git add . } -# Prompt the user for a specific variable. The variable is the first -# input, the second is an optional description. -# The third argument can be a suggested answer, already pre populated. +# Prompt the user for a specific variable. +# ## Args: +# [1]: Name of the variable to populate the answer to +# [2]: An optional description +# [3]: An optionally suggested answer +# [4]: If this is set, the user is not even asked. prompt() { pr_variable_upper="$(echo "$1" | sed 's/\([a-z]\)/\U\1/')" pr_description="$2" pr_suggested_answer="$3" + pr_ask="$4" - printf "\033[94;1mEnter %s\033[0m" "$pr_variable_upper" - if [ -n "$pr_description" ];then - printf " (\033[93;1m%s\033[0m):\n" "$pr_description" + if [ -n "$pr_ask" ]; then + REPLY="$pr_suggested_answer"; else - printf ":\n" + printf "\033[94;1mEnter %s\033[0m" "$pr_variable_upper" + if [ -n "$pr_description" ];then + printf " (\033[93;1m%s\033[0m):\n" "$pr_description" + else + printf ":\n" + fi + + # LE "> " 0 " " "$pr_suggested_answer" "yes_please_produce_debug_output" + LE "> " 0 " " "$pr_suggested_answer" "" fi - # LE "> " 0 " " "$pr_suggested_answer" "yes_please_produce_debug_output" - LE "> " 0 " " "$pr_suggested_answer" "" - pr_new_variable="$(printf '%s="%s"' "$pr_variable_upper" "$REPLY")" eval "$pr_new_variable" @@ -43,7 +50,10 @@ 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)" "$(basename "$PWD" | sed 's/\([a-z]\)/\u\1/')" +prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/\([a-z]\)/\u\1/')" +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/\([a-z]\)/\U\1(1)/')" "dont_ask" +prompt APPLICATION_VERSION "The version of this program, without the prefix" "0.1.0" + prompt AUTHOR_NAME "The name of the author (or authors)" "$(git config --get user.name)" prompt AUTHOR_EMAIL "The email of the author (or authors)" "$(git config --get user.email)" @@ -54,6 +64,8 @@ prompt OWNER "The name of owner of the repository" "$AUTHOR_NAME" # nice meta data prompt DESCRIPTION "The description of this project" "[can be empty]" +prompt CURRENT_DATE "The stylized version of the current date" "$(date +'%b %Y')" +prompt YEAR "The year the work on this has begun (for copyright reasons)" "$(date +'%Y')" # LICENSE.spdx data (source: https://github.com/david-a-wheeler/spdx-tutorial) prompt APPLICATION_ORIGINATOR "The person or organization from whom the package originally came" "$AUTHOR_NAME" @@ -67,5 +79,18 @@ while read -r var; do var_value="${var_value%\"}" fd . --hidden --type file --exec sed --in-place "s|%\bINIT_$var_name\b|$var_value|" + + # Replace the variable in file paths + fd "%INIT_$var_name" . --hidden | while read -r file_path; do + new_file_path="$(echo "$file_path" | sed "s|%INIT_$var_name|$var_value|")"; + mv "$file_path" "$new_file_path" + done done < "$replacement_file" + +# HACK: Re-add the executable permissions to files, which the nix template has somehow +# removed <2024-04-02> +chmod +x scripts/* +chmod +x update.sh +[ -f ./build.sh ] && chmod +x build.sh + # vim: ft=sh diff --git a/templates/awk/treefmt.nix b/templates/awk/treefmt.nix index 1cbab40..540a6ca 100644 --- a/templates/awk/treefmt.nix +++ b/templates/awk/treefmt.nix @@ -59,6 +59,7 @@ treefmt-nix.lib.evalModule pkgs ( global.excludes = [ "CHANGELOG.md" "NEWS.md" + "%INIT_APPLICATION_NAME.1.md" ]; formatter = { clang-format = { diff --git a/templates/c/.licensure.yml b/templates/c/.licensure.yml index 942a96f..60ef45c 100644 --- a/templates/c/.licensure.yml +++ b/templates/c/.licensure.yml @@ -22,10 +22,10 @@ licenses: email: "%INIT_AUTHOR_EMAIL" template: | - TODO 2024 - [year] (C) by [name of author] + %INIT_APPLIACATION_NAME_STYLIZED %INIT_YEAR - [year] (C) by [name of author] SPDX-License-Identifier: CC-BY-SA-4.0 - TODO is licensed under a + %INIT_APPLIACATION_NAME_STYLIZED is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. You should have received a copy of the license along with this @@ -51,9 +51,9 @@ licenses: # A list of authors who hold copyright over these files authors: # Provide either your full name or company name for copyright purposes - - name: Benedikt Peetz + - name: "%INIT_AUTHOR_NAME" # Optionally provide email for copyright purposes - email: "benedikt.peetz@b-peetz.de" + email: "%INIT_AUTHOR_EMAIL" # The template that will be rendered to generate the header before # comment characters are applied. Available variables are: @@ -63,13 +63,13 @@ licenses: # Name <email@example.com>. If multiple authors are provided the # list is concatenated together with commas. template: | - Copyright (C) 2023 - [year]: + Copyright (C) %INIT_YEAR - [year]: [name of author] SPDX-License-Identifier: GPL-3.0-or-later - This file is part of the TODO. + This file is part of %INIT_APPLICATION_NAME_STYLIZED. - TODO is free software: you can redistribute it and/or modify + %INIT_APPLICATION_NAME_STYLIZED is free software: you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/templates/c/docs/%INIT_APPLICATION_NAME.1.md b/templates/c/docs/%INIT_APPLICATION_NAME.1.md new file mode 100644 index 0000000..0a7ec9d --- /dev/null +++ b/templates/c/docs/%INIT_APPLICATION_NAME.1.md @@ -0,0 +1,54 @@ +% %INIT_APPLICATION_NAME_CAPITALIZED_MAN_PART %INIT_APPLICATION_NAME %INIT_APPLICATION_VERSION +% %INIT_AUTHOR_NAME +% %INIT_CURRENT_DATE + +# NAME + +%INIT_APPLICATION_NAME - %INIT_DESCRIPTION + +# SYNOPSIS + +**%INIT_APPLICATION_NAME** \[*--help*|*--version*\] + +# DESCRIPTION + +TODO + +# OPTIONS + +**--help**, **-h** +: Displays a help message and exit. + +**--version**, **-v** +: Displays the software version and exit. + +# EXAMPLES + +**%INIT_APPLICATION_NAME** +: TODO. See the Description section for further details. + +# FILES + +*name.file* +: This file is important because it does x. + +# BUGS + +Report bugs to <https://%INIT_REMOTE/%INIT_OWNER/%INIT_REPOSITORY/issues>. + +# COPYRIGHT + +Copyright (C) %INIT_YEAR %INIT_AUTOHR_NAME + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/templates/c/docs/TODO.1.md b/templates/c/docs/TODO.1.md deleted file mode 100644 index e14fec5..0000000 --- a/templates/c/docs/TODO.1.md +++ /dev/null @@ -1,70 +0,0 @@ -% FUPDATE(1) fupdate 1.0.0 -% Benedikt Peetz -% May 2023 - -# NAME - -fupdate - updates your flake, while checking for common mistakes - -# SYNOPSIS - -**fupdate** list of \[*flake*|*\<some word>*|*--help*|*-h*\] - -# DESCRIPTION - -Argument can be stacked, this makes it possible to specify multiple targets to be updated in succession. See the Examples section for further details. - -No argument or *flake* -: **fupdate**, when executed without arguments or with *flake*, will update your *flake.lock*, check for duplicate flake inputs, i.e., an input has an input declared, which you have also declared as input, and will run a script called *update.sh*, if you allow it. -The allowance for the script is asked, when you run **fupdate** and the found script is not yet allowed. Furthermore, the allowance is based on the concrete sha256 hash of the script, so any changes will require another allowance. - -**\<some word>** as argument -: If the executable **update-\<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit. - -# OPTIONS - -**--help**, **-h** -: Displays a help message and exit. - -**--version**, **-v** -: Displays the software version and exit. - -# EXAMPLES - -**fupdate** or **fupdate flake** -: Updates your *flake.lock*. See the Description section for further details. - -**fupdate sys** -: Run the executable **update-sys**, if it exists. See the Description section for further details. - -**fupdate flake sys docs** -: First updates your flake, then, if the command succeeded, runs **update-sys**, afterweich **update-docs** is run. - -# FILES - -*update.sh* -: This is supposed to be a shell script located in your flake base directory, i.e., the directory which contains both a *flake.nix* and a *flake.lock* file. - -*~/.local/share/flake-update/* -: **fupdate** will store the hashes to the allowed *update.sh* files here. - -# BUGS - -Report bugs to <https://codeberg.org/soispha/flake_update/issues>. - -# COPYRIGHT - -Copyright (C) 2023 Benedikt Peetz - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/templates/c/init b/templates/c/init index 787b663..df0b4c5 100755 --- a/templates/c/init +++ b/templates/c/init @@ -5,34 +5,41 @@ replacement_file="$(mktemp)" trap cleanup INT -trap "cleanup; remove" EXIT +trap "cleanup; remove_self" EXIT cleanup() { rm "$replacement_file" } -remove() { +remove_self() { rm "$(realpath "$0")" rm "$(realpath "$(dirname "$0")")/shell_line_editor.sh" - git add . } -# Prompt the user for a specific variable. The variable is the first -# input, the second is an optional description. -# The third argument can be a suggested answer, already pre populated. +# Prompt the user for a specific variable. +# ## Args: +# [1]: Name of the variable to populate the answer to +# [2]: An optional description +# [3]: An optionally suggested answer +# [4]: If this is set, the user is not even asked. prompt() { pr_variable_upper="$(echo "$1" | sed 's/\([a-z]\)/\U\1/')" pr_description="$2" pr_suggested_answer="$3" + pr_ask="$4" - printf "\033[94;1mEnter %s\033[0m" "$pr_variable_upper" - if [ -n "$pr_description" ];then - printf " (\033[93;1m%s\033[0m):\n" "$pr_description" + if [ -n "$pr_ask" ]; then + REPLY="$pr_suggested_answer"; else - printf ":\n" + printf "\033[94;1mEnter %s\033[0m" "$pr_variable_upper" + if [ -n "$pr_description" ];then + printf " (\033[93;1m%s\033[0m):\n" "$pr_description" + else + printf ":\n" + fi + + # LE "> " 0 " " "$pr_suggested_answer" "yes_please_produce_debug_output" + LE "> " 0 " " "$pr_suggested_answer" "" fi - # LE "> " 0 " " "$pr_suggested_answer" "yes_please_produce_debug_output" - LE "> " 0 " " "$pr_suggested_answer" "" - pr_new_variable="$(printf '%s="%s"' "$pr_variable_upper" "$REPLY")" eval "$pr_new_variable" @@ -43,7 +50,10 @@ 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)" "$(basename "$PWD" | sed 's/\([a-z]\)/\u\1/')" +prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/\([a-z]\)/\u\1/')" +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/\([a-z]\)/\U\1(1)/')" "dont_ask" +prompt APPLICATION_VERSION "The version of this program, without the prefix" "0.1.0" + prompt AUTHOR_NAME "The name of the author (or authors)" "$(git config --get user.name)" prompt AUTHOR_EMAIL "The email of the author (or authors)" "$(git config --get user.email)" @@ -54,6 +64,8 @@ prompt OWNER "The name of owner of the repository" "$AUTHOR_NAME" # nice meta data prompt DESCRIPTION "The description of this project" "[can be empty]" +prompt CURRENT_DATE "The stylized version of the current date" "$(date +'%b %Y')" +prompt YEAR "The year the work on this has begun (for copyright reasons)" "$(date +'%Y')" # LICENSE.spdx data (source: https://github.com/david-a-wheeler/spdx-tutorial) prompt APPLICATION_ORIGINATOR "The person or organization from whom the package originally came" "$AUTHOR_NAME" @@ -67,5 +79,18 @@ while read -r var; do var_value="${var_value%\"}" fd . --hidden --type file --exec sed --in-place "s|%\bINIT_$var_name\b|$var_value|" + + # Replace the variable in file paths + fd "%INIT_$var_name" . --hidden | while read -r file_path; do + new_file_path="$(echo "$file_path" | sed "s|%INIT_$var_name|$var_value|")"; + mv "$file_path" "$new_file_path" + done done < "$replacement_file" + +# HACK: Re-add the executable permissions to files, which the nix template has somehow +# removed <2024-04-02> +chmod +x scripts/* +chmod +x update.sh +[ -f ./build.sh ] && chmod +x build.sh + # vim: ft=sh diff --git a/templates/c/treefmt.nix b/templates/c/treefmt.nix index 1cbab40..540a6ca 100644 --- a/templates/c/treefmt.nix +++ b/templates/c/treefmt.nix @@ -59,6 +59,7 @@ treefmt-nix.lib.evalModule pkgs ( global.excludes = [ "CHANGELOG.md" "NEWS.md" + "%INIT_APPLICATION_NAME.1.md" ]; formatter = { clang-format = { diff --git a/templates/latex/.licensure.yml b/templates/latex/.licensure.yml index 942a96f..60ef45c 100644 --- a/templates/latex/.licensure.yml +++ b/templates/latex/.licensure.yml @@ -22,10 +22,10 @@ licenses: email: "%INIT_AUTHOR_EMAIL" template: | - TODO 2024 - [year] (C) by [name of author] + %INIT_APPLIACATION_NAME_STYLIZED %INIT_YEAR - [year] (C) by [name of author] SPDX-License-Identifier: CC-BY-SA-4.0 - TODO is licensed under a + %INIT_APPLIACATION_NAME_STYLIZED is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. You should have received a copy of the license along with this @@ -51,9 +51,9 @@ licenses: # A list of authors who hold copyright over these files authors: # Provide either your full name or company name for copyright purposes - - name: Benedikt Peetz + - name: "%INIT_AUTHOR_NAME" # Optionally provide email for copyright purposes - email: "benedikt.peetz@b-peetz.de" + email: "%INIT_AUTHOR_EMAIL" # The template that will be rendered to generate the header before # comment characters are applied. Available variables are: @@ -63,13 +63,13 @@ licenses: # Name <email@example.com>. If multiple authors are provided the # list is concatenated together with commas. template: | - Copyright (C) 2023 - [year]: + Copyright (C) %INIT_YEAR - [year]: [name of author] SPDX-License-Identifier: GPL-3.0-or-later - This file is part of the TODO. + This file is part of %INIT_APPLICATION_NAME_STYLIZED. - TODO is free software: you can redistribute it and/or modify + %INIT_APPLICATION_NAME_STYLIZED is free software: you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/templates/latex/init b/templates/latex/init index 787b663..df0b4c5 100755 --- a/templates/latex/init +++ b/templates/latex/init @@ -5,34 +5,41 @@ replacement_file="$(mktemp)" trap cleanup INT -trap "cleanup; remove" EXIT +trap "cleanup; remove_self" EXIT cleanup() { rm "$replacement_file" } -remove() { +remove_self() { rm "$(realpath "$0")" rm "$(realpath "$(dirname "$0")")/shell_line_editor.sh" - git add . } -# Prompt the user for a specific variable. The variable is the first -# input, the second is an optional description. -# The third argument can be a suggested answer, already pre populated. +# Prompt the user for a specific variable. +# ## Args: +# [1]: Name of the variable to populate the answer to +# [2]: An optional description +# [3]: An optionally suggested answer +# [4]: If this is set, the user is not even asked. prompt() { pr_variable_upper="$(echo "$1" | sed 's/\([a-z]\)/\U\1/')" pr_description="$2" pr_suggested_answer="$3" + pr_ask="$4" - printf "\033[94;1mEnter %s\033[0m" "$pr_variable_upper" - if [ -n "$pr_description" ];then - printf " (\033[93;1m%s\033[0m):\n" "$pr_description" + if [ -n "$pr_ask" ]; then + REPLY="$pr_suggested_answer"; else - printf ":\n" + printf "\033[94;1mEnter %s\033[0m" "$pr_variable_upper" + if [ -n "$pr_description" ];then + printf " (\033[93;1m%s\033[0m):\n" "$pr_description" + else + printf ":\n" + fi + + # LE "> " 0 " " "$pr_suggested_answer" "yes_please_produce_debug_output" + LE "> " 0 " " "$pr_suggested_answer" "" fi - # LE "> " 0 " " "$pr_suggested_answer" "yes_please_produce_debug_output" - LE "> " 0 " " "$pr_suggested_answer" "" - pr_new_variable="$(printf '%s="%s"' "$pr_variable_upper" "$REPLY")" eval "$pr_new_variable" @@ -43,7 +50,10 @@ 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)" "$(basename "$PWD" | sed 's/\([a-z]\)/\u\1/')" +prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/\([a-z]\)/\u\1/')" +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/\([a-z]\)/\U\1(1)/')" "dont_ask" +prompt APPLICATION_VERSION "The version of this program, without the prefix" "0.1.0" + prompt AUTHOR_NAME "The name of the author (or authors)" "$(git config --get user.name)" prompt AUTHOR_EMAIL "The email of the author (or authors)" "$(git config --get user.email)" @@ -54,6 +64,8 @@ prompt OWNER "The name of owner of the repository" "$AUTHOR_NAME" # nice meta data prompt DESCRIPTION "The description of this project" "[can be empty]" +prompt CURRENT_DATE "The stylized version of the current date" "$(date +'%b %Y')" +prompt YEAR "The year the work on this has begun (for copyright reasons)" "$(date +'%Y')" # LICENSE.spdx data (source: https://github.com/david-a-wheeler/spdx-tutorial) prompt APPLICATION_ORIGINATOR "The person or organization from whom the package originally came" "$AUTHOR_NAME" @@ -67,5 +79,18 @@ while read -r var; do var_value="${var_value%\"}" fd . --hidden --type file --exec sed --in-place "s|%\bINIT_$var_name\b|$var_value|" + + # Replace the variable in file paths + fd "%INIT_$var_name" . --hidden | while read -r file_path; do + new_file_path="$(echo "$file_path" | sed "s|%INIT_$var_name|$var_value|")"; + mv "$file_path" "$new_file_path" + done done < "$replacement_file" + +# HACK: Re-add the executable permissions to files, which the nix template has somehow +# removed <2024-04-02> +chmod +x scripts/* +chmod +x update.sh +[ -f ./build.sh ] && chmod +x build.sh + # vim: ft=sh diff --git a/templates/latex/treefmt.nix b/templates/latex/treefmt.nix index 1cbab40..540a6ca 100644 --- a/templates/latex/treefmt.nix +++ b/templates/latex/treefmt.nix @@ -59,6 +59,7 @@ treefmt-nix.lib.evalModule pkgs ( global.excludes = [ "CHANGELOG.md" "NEWS.md" + "%INIT_APPLICATION_NAME.1.md" ]; formatter = { clang-format = { diff --git a/templates/rust/.licensure.yml b/templates/rust/.licensure.yml index 942a96f..60ef45c 100644 --- a/templates/rust/.licensure.yml +++ b/templates/rust/.licensure.yml @@ -22,10 +22,10 @@ licenses: email: "%INIT_AUTHOR_EMAIL" template: | - TODO 2024 - [year] (C) by [name of author] + %INIT_APPLIACATION_NAME_STYLIZED %INIT_YEAR - [year] (C) by [name of author] SPDX-License-Identifier: CC-BY-SA-4.0 - TODO is licensed under a + %INIT_APPLIACATION_NAME_STYLIZED is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. You should have received a copy of the license along with this @@ -51,9 +51,9 @@ licenses: # A list of authors who hold copyright over these files authors: # Provide either your full name or company name for copyright purposes - - name: Benedikt Peetz + - name: "%INIT_AUTHOR_NAME" # Optionally provide email for copyright purposes - email: "benedikt.peetz@b-peetz.de" + email: "%INIT_AUTHOR_EMAIL" # The template that will be rendered to generate the header before # comment characters are applied. Available variables are: @@ -63,13 +63,13 @@ licenses: # Name <email@example.com>. If multiple authors are provided the # list is concatenated together with commas. template: | - Copyright (C) 2023 - [year]: + Copyright (C) %INIT_YEAR - [year]: [name of author] SPDX-License-Identifier: GPL-3.0-or-later - This file is part of the TODO. + This file is part of %INIT_APPLICATION_NAME_STYLIZED. - TODO is free software: you can redistribute it and/or modify + %INIT_APPLICATION_NAME_STYLIZED is free software: you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/templates/rust/docs/%INIT_APPLICATION_NAME.1.md b/templates/rust/docs/%INIT_APPLICATION_NAME.1.md new file mode 100644 index 0000000..0a7ec9d --- /dev/null +++ b/templates/rust/docs/%INIT_APPLICATION_NAME.1.md @@ -0,0 +1,54 @@ +% %INIT_APPLICATION_NAME_CAPITALIZED_MAN_PART %INIT_APPLICATION_NAME %INIT_APPLICATION_VERSION +% %INIT_AUTHOR_NAME +% %INIT_CURRENT_DATE + +# NAME + +%INIT_APPLICATION_NAME - %INIT_DESCRIPTION + +# SYNOPSIS + +**%INIT_APPLICATION_NAME** \[*--help*|*--version*\] + +# DESCRIPTION + +TODO + +# OPTIONS + +**--help**, **-h** +: Displays a help message and exit. + +**--version**, **-v** +: Displays the software version and exit. + +# EXAMPLES + +**%INIT_APPLICATION_NAME** +: TODO. See the Description section for further details. + +# FILES + +*name.file* +: This file is important because it does x. + +# BUGS + +Report bugs to <https://%INIT_REMOTE/%INIT_OWNER/%INIT_REPOSITORY/issues>. + +# COPYRIGHT + +Copyright (C) %INIT_YEAR %INIT_AUTOHR_NAME + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/templates/rust/docs/TODO.1.md b/templates/rust/docs/TODO.1.md deleted file mode 100644 index e14fec5..0000000 --- a/templates/rust/docs/TODO.1.md +++ /dev/null @@ -1,70 +0,0 @@ -% FUPDATE(1) fupdate 1.0.0 -% Benedikt Peetz -% May 2023 - -# NAME - -fupdate - updates your flake, while checking for common mistakes - -# SYNOPSIS - -**fupdate** list of \[*flake*|*\<some word>*|*--help*|*-h*\] - -# DESCRIPTION - -Argument can be stacked, this makes it possible to specify multiple targets to be updated in succession. See the Examples section for further details. - -No argument or *flake* -: **fupdate**, when executed without arguments or with *flake*, will update your *flake.lock*, check for duplicate flake inputs, i.e., an input has an input declared, which you have also declared as input, and will run a script called *update.sh*, if you allow it. -The allowance for the script is asked, when you run **fupdate** and the found script is not yet allowed. Furthermore, the allowance is based on the concrete sha256 hash of the script, so any changes will require another allowance. - -**\<some word>** as argument -: If the executable **update-\<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit. - -# OPTIONS - -**--help**, **-h** -: Displays a help message and exit. - -**--version**, **-v** -: Displays the software version and exit. - -# EXAMPLES - -**fupdate** or **fupdate flake** -: Updates your *flake.lock*. See the Description section for further details. - -**fupdate sys** -: Run the executable **update-sys**, if it exists. See the Description section for further details. - -**fupdate flake sys docs** -: First updates your flake, then, if the command succeeded, runs **update-sys**, afterweich **update-docs** is run. - -# FILES - -*update.sh* -: This is supposed to be a shell script located in your flake base directory, i.e., the directory which contains both a *flake.nix* and a *flake.lock* file. - -*~/.local/share/flake-update/* -: **fupdate** will store the hashes to the allowed *update.sh* files here. - -# BUGS - -Report bugs to <https://codeberg.org/soispha/flake_update/issues>. - -# COPYRIGHT - -Copyright (C) 2023 Benedikt Peetz - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/templates/rust/init b/templates/rust/init index 787b663..df0b4c5 100755 --- a/templates/rust/init +++ b/templates/rust/init @@ -5,34 +5,41 @@ replacement_file="$(mktemp)" trap cleanup INT -trap "cleanup; remove" EXIT +trap "cleanup; remove_self" EXIT cleanup() { rm "$replacement_file" } -remove() { +remove_self() { rm "$(realpath "$0")" rm "$(realpath "$(dirname "$0")")/shell_line_editor.sh" - git add . } -# Prompt the user for a specific variable. The variable is the first -# input, the second is an optional description. -# The third argument can be a suggested answer, already pre populated. +# Prompt the user for a specific variable. +# ## Args: +# [1]: Name of the variable to populate the answer to +# [2]: An optional description +# [3]: An optionally suggested answer +# [4]: If this is set, the user is not even asked. prompt() { pr_variable_upper="$(echo "$1" | sed 's/\([a-z]\)/\U\1/')" pr_description="$2" pr_suggested_answer="$3" + pr_ask="$4" - printf "\033[94;1mEnter %s\033[0m" "$pr_variable_upper" - if [ -n "$pr_description" ];then - printf " (\033[93;1m%s\033[0m):\n" "$pr_description" + if [ -n "$pr_ask" ]; then + REPLY="$pr_suggested_answer"; else - printf ":\n" + printf "\033[94;1mEnter %s\033[0m" "$pr_variable_upper" + if [ -n "$pr_description" ];then + printf " (\033[93;1m%s\033[0m):\n" "$pr_description" + else + printf ":\n" + fi + + # LE "> " 0 " " "$pr_suggested_answer" "yes_please_produce_debug_output" + LE "> " 0 " " "$pr_suggested_answer" "" fi - # LE "> " 0 " " "$pr_suggested_answer" "yes_please_produce_debug_output" - LE "> " 0 " " "$pr_suggested_answer" "" - pr_new_variable="$(printf '%s="%s"' "$pr_variable_upper" "$REPLY")" eval "$pr_new_variable" @@ -43,7 +50,10 @@ 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)" "$(basename "$PWD" | sed 's/\([a-z]\)/\u\1/')" +prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/\([a-z]\)/\u\1/')" +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/\([a-z]\)/\U\1(1)/')" "dont_ask" +prompt APPLICATION_VERSION "The version of this program, without the prefix" "0.1.0" + prompt AUTHOR_NAME "The name of the author (or authors)" "$(git config --get user.name)" prompt AUTHOR_EMAIL "The email of the author (or authors)" "$(git config --get user.email)" @@ -54,6 +64,8 @@ prompt OWNER "The name of owner of the repository" "$AUTHOR_NAME" # nice meta data prompt DESCRIPTION "The description of this project" "[can be empty]" +prompt CURRENT_DATE "The stylized version of the current date" "$(date +'%b %Y')" +prompt YEAR "The year the work on this has begun (for copyright reasons)" "$(date +'%Y')" # LICENSE.spdx data (source: https://github.com/david-a-wheeler/spdx-tutorial) prompt APPLICATION_ORIGINATOR "The person or organization from whom the package originally came" "$AUTHOR_NAME" @@ -67,5 +79,18 @@ while read -r var; do var_value="${var_value%\"}" fd . --hidden --type file --exec sed --in-place "s|%\bINIT_$var_name\b|$var_value|" + + # Replace the variable in file paths + fd "%INIT_$var_name" . --hidden | while read -r file_path; do + new_file_path="$(echo "$file_path" | sed "s|%INIT_$var_name|$var_value|")"; + mv "$file_path" "$new_file_path" + done done < "$replacement_file" + +# HACK: Re-add the executable permissions to files, which the nix template has somehow +# removed <2024-04-02> +chmod +x scripts/* +chmod +x update.sh +[ -f ./build.sh ] && chmod +x build.sh + # vim: ft=sh diff --git a/templates/rust/treefmt.nix b/templates/rust/treefmt.nix index 1cbab40..540a6ca 100644 --- a/templates/rust/treefmt.nix +++ b/templates/rust/treefmt.nix @@ -59,6 +59,7 @@ treefmt-nix.lib.evalModule pkgs ( global.excludes = [ "CHANGELOG.md" "NEWS.md" + "%INIT_APPLICATION_NAME.1.md" ]; formatter = { clang-format = { diff --git a/templates/shell/.licensure.yml b/templates/shell/.licensure.yml index 942a96f..60ef45c 100644 --- a/templates/shell/.licensure.yml +++ b/templates/shell/.licensure.yml @@ -22,10 +22,10 @@ licenses: email: "%INIT_AUTHOR_EMAIL" template: | - TODO 2024 - [year] (C) by [name of author] + %INIT_APPLIACATION_NAME_STYLIZED %INIT_YEAR - [year] (C) by [name of author] SPDX-License-Identifier: CC-BY-SA-4.0 - TODO is licensed under a + %INIT_APPLIACATION_NAME_STYLIZED is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. You should have received a copy of the license along with this @@ -51,9 +51,9 @@ licenses: # A list of authors who hold copyright over these files authors: # Provide either your full name or company name for copyright purposes - - name: Benedikt Peetz + - name: "%INIT_AUTHOR_NAME" # Optionally provide email for copyright purposes - email: "benedikt.peetz@b-peetz.de" + email: "%INIT_AUTHOR_EMAIL" # The template that will be rendered to generate the header before # comment characters are applied. Available variables are: @@ -63,13 +63,13 @@ licenses: # Name <email@example.com>. If multiple authors are provided the # list is concatenated together with commas. template: | - Copyright (C) 2023 - [year]: + Copyright (C) %INIT_YEAR - [year]: [name of author] SPDX-License-Identifier: GPL-3.0-or-later - This file is part of the TODO. + This file is part of %INIT_APPLICATION_NAME_STYLIZED. - TODO is free software: you can redistribute it and/or modify + %INIT_APPLICATION_NAME_STYLIZED is free software: you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/templates/shell/docs/%INIT_APPLICATION_NAME.1.md b/templates/shell/docs/%INIT_APPLICATION_NAME.1.md new file mode 100644 index 0000000..0a7ec9d --- /dev/null +++ b/templates/shell/docs/%INIT_APPLICATION_NAME.1.md @@ -0,0 +1,54 @@ +% %INIT_APPLICATION_NAME_CAPITALIZED_MAN_PART %INIT_APPLICATION_NAME %INIT_APPLICATION_VERSION +% %INIT_AUTHOR_NAME +% %INIT_CURRENT_DATE + +# NAME + +%INIT_APPLICATION_NAME - %INIT_DESCRIPTION + +# SYNOPSIS + +**%INIT_APPLICATION_NAME** \[*--help*|*--version*\] + +# DESCRIPTION + +TODO + +# OPTIONS + +**--help**, **-h** +: Displays a help message and exit. + +**--version**, **-v** +: Displays the software version and exit. + +# EXAMPLES + +**%INIT_APPLICATION_NAME** +: TODO. See the Description section for further details. + +# FILES + +*name.file* +: This file is important because it does x. + +# BUGS + +Report bugs to <https://%INIT_REMOTE/%INIT_OWNER/%INIT_REPOSITORY/issues>. + +# COPYRIGHT + +Copyright (C) %INIT_YEAR %INIT_AUTOHR_NAME + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/templates/shell/docs/TODO.1.md b/templates/shell/docs/TODO.1.md deleted file mode 100644 index e14fec5..0000000 --- a/templates/shell/docs/TODO.1.md +++ /dev/null @@ -1,70 +0,0 @@ -% FUPDATE(1) fupdate 1.0.0 -% Benedikt Peetz -% May 2023 - -# NAME - -fupdate - updates your flake, while checking for common mistakes - -# SYNOPSIS - -**fupdate** list of \[*flake*|*\<some word>*|*--help*|*-h*\] - -# DESCRIPTION - -Argument can be stacked, this makes it possible to specify multiple targets to be updated in succession. See the Examples section for further details. - -No argument or *flake* -: **fupdate**, when executed without arguments or with *flake*, will update your *flake.lock*, check for duplicate flake inputs, i.e., an input has an input declared, which you have also declared as input, and will run a script called *update.sh*, if you allow it. -The allowance for the script is asked, when you run **fupdate** and the found script is not yet allowed. Furthermore, the allowance is based on the concrete sha256 hash of the script, so any changes will require another allowance. - -**\<some word>** as argument -: If the executable **update-\<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit. - -# OPTIONS - -**--help**, **-h** -: Displays a help message and exit. - -**--version**, **-v** -: Displays the software version and exit. - -# EXAMPLES - -**fupdate** or **fupdate flake** -: Updates your *flake.lock*. See the Description section for further details. - -**fupdate sys** -: Run the executable **update-sys**, if it exists. See the Description section for further details. - -**fupdate flake sys docs** -: First updates your flake, then, if the command succeeded, runs **update-sys**, afterweich **update-docs** is run. - -# FILES - -*update.sh* -: This is supposed to be a shell script located in your flake base directory, i.e., the directory which contains both a *flake.nix* and a *flake.lock* file. - -*~/.local/share/flake-update/* -: **fupdate** will store the hashes to the allowed *update.sh* files here. - -# BUGS - -Report bugs to <https://codeberg.org/soispha/flake_update/issues>. - -# COPYRIGHT - -Copyright (C) 2023 Benedikt Peetz - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/templates/shell/init b/templates/shell/init index 787b663..df0b4c5 100755 --- a/templates/shell/init +++ b/templates/shell/init @@ -5,34 +5,41 @@ replacement_file="$(mktemp)" trap cleanup INT -trap "cleanup; remove" EXIT +trap "cleanup; remove_self" EXIT cleanup() { rm "$replacement_file" } -remove() { +remove_self() { rm "$(realpath "$0")" rm "$(realpath "$(dirname "$0")")/shell_line_editor.sh" - git add . } -# Prompt the user for a specific variable. The variable is the first -# input, the second is an optional description. -# The third argument can be a suggested answer, already pre populated. +# Prompt the user for a specific variable. +# ## Args: +# [1]: Name of the variable to populate the answer to +# [2]: An optional description +# [3]: An optionally suggested answer +# [4]: If this is set, the user is not even asked. prompt() { pr_variable_upper="$(echo "$1" | sed 's/\([a-z]\)/\U\1/')" pr_description="$2" pr_suggested_answer="$3" + pr_ask="$4" - printf "\033[94;1mEnter %s\033[0m" "$pr_variable_upper" - if [ -n "$pr_description" ];then - printf " (\033[93;1m%s\033[0m):\n" "$pr_description" + if [ -n "$pr_ask" ]; then + REPLY="$pr_suggested_answer"; else - printf ":\n" + printf "\033[94;1mEnter %s\033[0m" "$pr_variable_upper" + if [ -n "$pr_description" ];then + printf " (\033[93;1m%s\033[0m):\n" "$pr_description" + else + printf ":\n" + fi + + # LE "> " 0 " " "$pr_suggested_answer" "yes_please_produce_debug_output" + LE "> " 0 " " "$pr_suggested_answer" "" fi - # LE "> " 0 " " "$pr_suggested_answer" "yes_please_produce_debug_output" - LE "> " 0 " " "$pr_suggested_answer" "" - pr_new_variable="$(printf '%s="%s"' "$pr_variable_upper" "$REPLY")" eval "$pr_new_variable" @@ -43,7 +50,10 @@ 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)" "$(basename "$PWD" | sed 's/\([a-z]\)/\u\1/')" +prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/\([a-z]\)/\u\1/')" +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/\([a-z]\)/\U\1(1)/')" "dont_ask" +prompt APPLICATION_VERSION "The version of this program, without the prefix" "0.1.0" + prompt AUTHOR_NAME "The name of the author (or authors)" "$(git config --get user.name)" prompt AUTHOR_EMAIL "The email of the author (or authors)" "$(git config --get user.email)" @@ -54,6 +64,8 @@ prompt OWNER "The name of owner of the repository" "$AUTHOR_NAME" # nice meta data prompt DESCRIPTION "The description of this project" "[can be empty]" +prompt CURRENT_DATE "The stylized version of the current date" "$(date +'%b %Y')" +prompt YEAR "The year the work on this has begun (for copyright reasons)" "$(date +'%Y')" # LICENSE.spdx data (source: https://github.com/david-a-wheeler/spdx-tutorial) prompt APPLICATION_ORIGINATOR "The person or organization from whom the package originally came" "$AUTHOR_NAME" @@ -67,5 +79,18 @@ while read -r var; do var_value="${var_value%\"}" fd . --hidden --type file --exec sed --in-place "s|%\bINIT_$var_name\b|$var_value|" + + # Replace the variable in file paths + fd "%INIT_$var_name" . --hidden | while read -r file_path; do + new_file_path="$(echo "$file_path" | sed "s|%INIT_$var_name|$var_value|")"; + mv "$file_path" "$new_file_path" + done done < "$replacement_file" + +# HACK: Re-add the executable permissions to files, which the nix template has somehow +# removed <2024-04-02> +chmod +x scripts/* +chmod +x update.sh +[ -f ./build.sh ] && chmod +x build.sh + # vim: ft=sh diff --git a/templates/shell/treefmt.nix b/templates/shell/treefmt.nix index 1cbab40..540a6ca 100644 --- a/templates/shell/treefmt.nix +++ b/templates/shell/treefmt.nix @@ -59,6 +59,7 @@ treefmt-nix.lib.evalModule pkgs ( global.excludes = [ "CHANGELOG.md" "NEWS.md" + "%INIT_APPLICATION_NAME.1.md" ]; formatter = { clang-format = { |