From 3c36fc3963a39c58c9a2c21f1e746ced645993dd Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Mon, 12 Jan 2026 17:05:34 -0500 Subject: [PATCH] remove template system --- Makefile | 3 -- bin/yait | 50 +++++++++++++------------- t/default/c.stpl | 78 ----------------------------------------- t/default/ignore.stpl | 12 ------- t/default/makefile.stpl | 64 --------------------------------- t/default/readme.stpl | 48 ------------------------- t/default/sh.stpl | 49 -------------------------- 7 files changed, 24 insertions(+), 280 deletions(-) delete mode 100644 t/default/c.stpl delete mode 100644 t/default/ignore.stpl delete mode 100644 t/default/makefile.stpl delete mode 100644 t/default/readme.stpl delete mode 100644 t/default/sh.stpl diff --git a/Makefile b/Makefile index 4318b37..57cc412 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,9 @@ all: install: cp bin/yait /usr/local/bin - mkdir -p /etc/yait - cp t/default/* /etc/yait cp yait.1 /usr/local/share/man/man1/yait.1 chmod 644 /usr/local/share/man/man1/yait.1 uninstall: $(RM) /usr/local/bin/yait - $(RM) -r /etc/yait $(RM) /usr/local/share/man/man1/yait.1 diff --git a/bin/yait b/bin/yait index bf86f45..32cc64f 100755 --- a/bin/yait +++ b/bin/yait @@ -12,16 +12,6 @@ scriptversion="1" # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -strip_comments() { - for file in "$@"; do - if [ ! -f "$file" ]; then - echo "Error: File '$file' does not exist." >&2 - return 1 - fi - sed 's/^[[:space:]]*;.*//; /^[[:space:]]*$/d' "$file" - done -} - me=$0 version="$me v$scriptversion @@ -40,25 +30,39 @@ Options: -x set project type -S small project creation -f overwrite existing files - -n set project name -a set project author -r initialize Git repository for the project -q surpress output" -x="C" -S= -f= -n= -a=$(git config user.name) -r= -q= +x=C # language +S= # small project creation (bool) +f= # force (bool) +a=$(git config user.name) # author +r= # initialize repository (bool) +q= # surpress output -mfmt() { +format() { if [ -z "$q" ]; then echo "$me: $*" fi } +create_project() { + name=$1 + + if ! echo "$name" | grep -qE '^[A-Za-z0-9_-]+$'; then + format "invalid name '$name'" + exit 1 + fi + + echo "invoke" +} + +if ! [ $# -gt 0 ]; then + echo "$usage" + exit 0 +fi + while [ $# -gt 0 ]; do case $1 in --help) echo "$usage"; exit 0 ;; @@ -66,16 +70,10 @@ while [ $# -gt 0 ]; do -x) shift; x=$1; break ;; -S) S=true; break ;; -f) f=true; break ;; - -n) shift; n=$1; break ;; -a) shift; a=$1; break ;; -r) r=true; break ;; -q) q=true; break ;; -*) echo "$me: Unknown option '$1'." >&2; exit 1 ;; - *) break ;; + *) create_project $1; shift ;; esac done - -if ! [ $# -gt 0 ]; then - echo "$usage" - exit 0 -fi diff --git a/t/default/c.stpl b/t/default/c.stpl deleted file mode 100644 index ecda0ae..0000000 --- a/t/default/c.stpl +++ /dev/null @@ -1,78 +0,0 @@ -; C file template -; -; -; This is the default C file template for the yait project init tool. This file -; is auto-generated on install and can be modified to your hearts content. An -; original copy can be found at /etc/yait/ -; - -@def main -/* - * main.c - * - * {{PACKAGE}}/{{AUTHOR}} 0.0.1 - * - * Copying policy - * - * {{PACKAGE}} 0.0.1 can be copied and distributed freely for any - * non-commercial purposes. {{PACKAGE}} 0.0.1 can only be incorporated - * into commercial software with the permission of the current author. - * - * This file contains the main driving routine. - * - */ - -#include -#include -#include - -#include "version.h" -#include "estruct.h" - -void usage(int status) -{ - printf("Usage: %s REQUIRED POSITIONAL ARGUMENT\n", PROGRAM_NAME); - printf(" or: %s [options]\n\n", PROGRAM_NAME); - fputs(" --help display this help and exit\n", stdout); - fputs(" --version output version information and exit\n", stdout); - - exit(status); -} - -int main(int argc, char **argv) -{ - int carg; - - if (argc == 2) { - if (strcmp(argv[1], "--help") == 0) { - usage(EXIT_FAILURE); - } - if (strcmp(argv[1], "--version") == 0) { - version(); - exit(EXIT_SUCCESS); - } - } - - puts(MESSAGE); - - return 0; -} -@end - -@def header -#ifndef {{MODULE}}_H_ -#define {{MODULE}}_H_ - -#endif /* {{MODULE}}_H_ */ -@end - -@def impl -/* {{MODULE}}.c - * - * The routines in this file handle **things** - * - * written by {{AUTHOR}} - */ - -#include "{{MODULE}}.h" -@end diff --git a/t/default/ignore.stpl b/t/default/ignore.stpl deleted file mode 100644 index d37d694..0000000 --- a/t/default/ignore.stpl +++ /dev/null @@ -1,12 +0,0 @@ -; Gitignore file template -; -; -; This is the default gitignore file template for the yait project init tool. This file -; is auto-generated on install and can be modified to your hearts content. An -; original copy can be found at /etc/yait/ -; -; This file is only included when the C project strucutre is used. -; - -{{PACKAGE}} -*.o diff --git a/t/default/makefile.stpl b/t/default/makefile.stpl deleted file mode 100644 index 6c7bc27..0000000 --- a/t/default/makefile.stpl +++ /dev/null @@ -1,64 +0,0 @@ -; Makefile file template -; -; -; This is the default Makefile file template for the yait project init tool. This file -; is auto-generated on install and can be modified to your hearts content. An -; original copy can be found at /etc/yait/ -; - -@def C -# Makefile for {{PACKAGE}} - -# Make the build silent by default -V = - -ifeq ($(strip $(V)),) - E = @echo - Q = @ -else - E = @\# - Q = -endif -export E Q - -PROGRAM = {{PACKAGE}} -TARBALL = $(PROGRAM).tar -SRC = $(wildcard *.c) -OBJ = $(SRC:.c=.o) -HDR = $(wildcard *.h) - -CC = gcc -WARNINGS = -Wall -Wstrict-prototypes -CFLAGS = -O2 $(WARNINGS) -g -DEFINES = -LIBS = -LDFLAGS = -BINDIR = /usr/bin -LIBDIR = /usr/lib - -$(PROGRAM): $(OBJ) $(HDR) - $(E) " LINK " $@ - $(Q) $(CC) $(LDFLAGS) $(DEFINES) -o $@ $(OBJ) $(LIBS) - -clean: - $(E) " CLEAN" - $(Q) rm -f $(PROGRAM) $(OBJ) - -install: $(PROGRAM) - cp $(PROGRAM) ${BINDIR} - -release: $(PROGRAM) - tar cvf $(TARBALL) $(SRC) $(HDR) Makefile README - -.c.o: - $(E) " CC " $@ - $(Q) $(CC) $(CFLAGS) $(DEFINES) -c $< -o $@ -@end - -@def sh -all: - @echo "nothing to do" - -install: - cp bin/{{PACKAGE}} /usr/local/bin -@end diff --git a/t/default/readme.stpl b/t/default/readme.stpl deleted file mode 100644 index 6b21e48..0000000 --- a/t/default/readme.stpl +++ /dev/null @@ -1,48 +0,0 @@ -; READMILE file template -; -; -; This is the default README file template for the yait project init tool. This -; file is auto-generated on install and can be modified to your hearts content. -; An original copy can be found at /etc/yait/ -; - -# {{PACKAGE}} - -https://example.com - -Tagline about your tool - -- Feature 1 -- Feature 2 - * sub point - -## Install - -#### Dependencies - -@def c -- `c compiler` - C compiler -@end - -@def sh -- `sh script` - A valid POSIX shell -@end - -**Note**: `tool` is used as a part of the build process. It does many things -such as runs, exists, and consisting of more than -1 bytes - -```bash -git clone https://example.com/git-tree -cd {{PACKAGE}} -@def c -make -@end -sudo make install -``` - -## Usage - -This tool runs via the command `{{PACKAGE}}`. - -- `{{PACKAGE}} --option1` -- Does a thing. -- `{{PACKAGE}} --option2` -- Does another thing. diff --git a/t/default/sh.stpl b/t/default/sh.stpl deleted file mode 100644 index cf1271f..0000000 --- a/t/default/sh.stpl +++ /dev/null @@ -1,49 +0,0 @@ -; SH file template -; -; -; This is the default SH file template for the yait project init tool. This file -; is auto-generated on install and can be modified to your hearts content. An -; original copy can be found at /etc/yait/ -; - -#! /bin/sh -# {{DESCRIPTION}} - -scriptversion="1" - -# -# -# Copyright (C) {{YEAR}} {{AUTHOR}} -# -# -# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -me=$0 -version="$me v$scriptversion - -Copyright (C) 2025-2026 vx-clutch. -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - -usage="\ -Usage: $me [OPTION]... -{{DESCRIPTION}} - -Options: - --help print this help and exit - --version output version information -" - -while [ $# -gt 0 ]; do - case $1 in - --help) echo "$usage"; exit 0 ;; - --version) echo "$version"; exit 0 ;; - -*) echo "$me: Unknown option '$1'." >&2; exit 1 ;; - *) break ;; - esac -done