From 82c7fbcb69de2b5b42f37c00995134c855cb2791 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Thu, 8 Jan 2026 16:09:43 +0000 Subject: [PATCH 01/20] Inital branch commit --- COPYING | 48 ++----- Makefile | 49 +------ edef.h | 18 --- estruct.h | 18 --- file.c | 77 ---------- file.h | 8 -- full.c | 79 ----------- full.h | 6 - git.c | 17 --- git.h | 6 - globals.c | 6 - input.c | 70 ---------- input.h | 9 -- main.c | 83 ----------- proj.c | 264 ----------------------------------- proj.h | 6 - scripts/git-hooks/pre-commit | 16 +++ shell.c | 77 ---------- shell.h | 6 - single.c | 20 --- single.h | 6 - usage.c | 22 --- usage.h | 6 - util.c | 10 -- util.h | 6 - version.c | 7 - version.h | 12 -- wrapper.c | 13 -- wrapper.h | 8 -- yait.1 | 0 30 files changed, 32 insertions(+), 941 deletions(-) delete mode 100644 edef.h delete mode 100644 estruct.h delete mode 100644 file.c delete mode 100644 file.h delete mode 100644 full.c delete mode 100644 full.h delete mode 100644 git.c delete mode 100644 git.h delete mode 100644 globals.c delete mode 100644 input.c delete mode 100644 input.h delete mode 100644 main.c delete mode 100644 proj.c delete mode 100644 proj.h create mode 100644 scripts/git-hooks/pre-commit delete mode 100644 shell.c delete mode 100644 shell.h delete mode 100644 single.c delete mode 100644 single.h delete mode 100644 usage.c delete mode 100644 usage.h delete mode 100644 util.c delete mode 100644 util.h delete mode 100644 version.c delete mode 100644 version.h delete mode 100644 wrapper.c delete mode 100644 wrapper.h create mode 100644 yait.1 diff --git a/COPYING b/COPYING index 7aefcab..b1f231d 100644 --- a/COPYING +++ b/COPYING @@ -1,39 +1,15 @@ -Copyright (c) 2025-2026 fSD version 1 +ISC License - This document is intended "as is", without modifications. +Copyright (c) 2025-2026 fSD -The binary and source code that this file is associated with and distributed -with is licensed under the following terms and conditions. +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Maintainers Note: - This section is reserved for any deviations of the prior notice. Given that - you are reading this, that means this document is assumed unmodified. Any - modifications in this section most follow this format: - - o the note. - - If a note is provided here the header the at top of the document must be - changed to reflect that as such: "This document is intended "as is", - without modifications." must become "This is a modified version of the - fSD general license. See Maintainers Note.". +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/Makefile b/Makefile index 534e845..c00aabf 100644 --- a/Makefile +++ b/Makefile @@ -1,46 +1,5 @@ -# Makefile for yait +all: + @echo "nothing to do" -# Make the build silent by default -V = - -ifeq ($(strip $(V)),) - E = @echo - Q = @ -else - E = @\# - Q = -endif -export E Q - -PROGRAM = yait -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 $@ +install: + cp bin/yait /usr/local/bin diff --git a/edef.h b/edef.h deleted file mode 100644 index 667163e..0000000 --- a/edef.h +++ /dev/null @@ -1,18 +0,0 @@ -/* edef.h - * - * Global variable definition - * - * written by vx-clutch - */ - -#ifndef EDEF_H_ -#define EDEF_H_ - -/* Initialized global external declarations. */ - -extern int git; - -/* Other constants declarations */ -enum { SINGLE, FULL }; - -#endif /* EDEF_H_ */ diff --git a/estruct.h b/estruct.h deleted file mode 100644 index 8555adf..0000000 --- a/estruct.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ESTRUCT_H_ -#define ESTRUCT_H_ - -/* Configuration options */ - -#define QLICENSE 0 /* Force use the default license option */ -#define LICENSE "BSD-3-Clause" /* Default SPDX-License-Identifier */ - -#define QAUTHOR 0 /* Force use the default author option */ -#define AUTHOR "fSD" /* Default author */ - -#define DEFAULT_GIT 0 /* Default git state */ - -/* Internal constants */ - -#define NPAT 128 - -#endif /* ESTRUCT_H_ */ diff --git a/file.c b/file.c deleted file mode 100644 index 51f3633..0000000 --- a/file.c +++ /dev/null @@ -1,77 +0,0 @@ -/* file.c - * - * The routines in this file handle the reading, writing - * and lookup of disk files. - * - * written by vx-clutch - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "file.h" -#include "estruct.h" - -int ffwrite(char *path, char *fmt, ...) { - FILE *f; - va_list ap; - int r; - - f = fopen(path, "w"); - if (!f) - return -1; - - va_start(ap, fmt); - r = vfprintf(f, fmt, ap); - va_end(ap); - - fclose(f); - return r < 0 ? -1 : 0; -} - -int fmkdir(char *fmt, ...) -{ - va_list ap; - char path[NPAT]; - char tmp[NPAT]; - char *p; - - va_start(ap, fmt); - vsnprintf(path, sizeof(path), fmt, ap); - va_end(ap); - - strncpy(tmp, path, sizeof(tmp) - 1); - tmp[sizeof(tmp) - 1] = '\0'; - - for (p = tmp + 1; *p; p++) { - if (*p == '/') { - *p = '\0'; - if (mkdir(tmp, 0755) < 0 && errno != EEXIST) - return -1; - *p = '/'; - } - } - - if (mkdir(tmp, 0755) < 0 && errno != EEXIST) - return -1; - - return 0; -} - -int ffexist(char *fmt, ...) { - char path[NPAT]; - va_list ap; - struct stat st; - - va_start(ap, fmt); - vsnprintf(path, sizeof(path), fmt, ap); - va_end(ap); - - return stat(path, &st) == 0; -} diff --git a/file.h b/file.h deleted file mode 100644 index 7fd9740..0000000 --- a/file.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef FILE_H_ -#define FILE_H_ - -int ffwrite(char *path, char *fmt, ...); -int fmkdir(char *path, ...); -int ffexist(char *fmt, ...); - -#endif /* FILE_H_ */ diff --git a/full.c b/full.c deleted file mode 100644 index d75c631..0000000 --- a/full.c +++ /dev/null @@ -1,79 +0,0 @@ -/* full.c - * - * Init to be called before project creation. - * - * written by vx-clutch - */ - -#include - -#include "file.h" -#include "full.h" -#include "usage.h" -#include "git.h" - -int full_project_init_and_cd(char *src) -{ - if (ffexist(src)) - die("%s already exists", src); - - fmkdir(src); - if (chdir(src)) - die("could not cd into %s", src); - - // TODO(vx-clutch): Take in interactive arguments all at once - ffwrite("README", "\ -+--------------------+\n\ -| package/Author 1.0 |\n\ -+--------------------+\n\ -\n\ - A project that does a thing 'well'.\n\ -\n\ - %s was written by ME!!!\n\ -\n\ - Copyright Notices:\n\ -\n\ - %s 1.0 (c) Copyright 2026 Author. \n\ - Reference the COPYING file for detailed information\n\ -\n\ -\n\ -WHAT IS package/Author?\n\ -\n\ -package/Author 1.0 is an optionated C and SH project generator. For C project\n\ -generation is produces a similar layout to the source of this project. On\n\ -SH it generates a shell script with useful useful scaffolding for a\n\ -script.\n\ -\n\ -\n\ -WHAT IS NEW\n\ -\n\ -Features:\n\ -\n\ -o This is the inital commit, EVERYTHING is new!\n\ -\n\ -Bug fixes - not very interesting:\n\ -\n\ -o None\n\ -\n\ -Something is gone:\n\ -\n\ -o None\n\ -\n\ -HOW TO INSTALL package/Author?\n\ -\n\ -o UNIX: Look at estruct.h, do a 'make', test the program, 'make install'.\n\ -\n\ -\n\ -ACKNOWLEDGEMENTS AND STATUS\n\ -\n\ -This project's file strucutre, file format, and certain contents are\n\ -derived from uEmacs/PK 4.0 specifically from the Linux Torvalds\n\ -distribution on GitHub. The README on from uEmacs/PK 4.0 has greater and\n\ -more accurate attributions, if you desire.\n\ -\n\ -LATE MODIFIED DATE", src, src); - - ginit(); /* initialize a git repository */ - - return 0; -} diff --git a/full.h b/full.h deleted file mode 100644 index a005515..0000000 --- a/full.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef FULL_H_ -#define FULL_H_ - -int full_project_init_and_cd(char *src); - -#endif /* FULL_H_ */ diff --git a/git.c b/git.c deleted file mode 100644 index 3e10277..0000000 --- a/git.c +++ /dev/null @@ -1,17 +0,0 @@ -/* git.c - * - * Routines for initilizing a git repository - * - * written by vx-clutch - */ - -#include "git.h" -#include "edef.h" -#include - -int ginit() -{ - if (git) return 0; - system("git init --quiet"); - return 0; -} diff --git a/git.h b/git.h deleted file mode 100644 index f19f486..0000000 --- a/git.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef GIT_H_ -#define GIT_H_ - -int ginit(); - -#endif /* GIT_H_ */ diff --git a/globals.c b/globals.c deleted file mode 100644 index e749145..0000000 --- a/globals.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "estruct.h" -#include "edef.h" - -/* initialized global definitions */ - -int git = DEFAULT_GIT; diff --git a/input.c b/input.c deleted file mode 100644 index b798e97..0000000 --- a/input.c +++ /dev/null @@ -1,70 +0,0 @@ -/* input.c - * - * Various input routines - * - * written by vx-clutch - */ - -#include -#include -#include -#include - -#include "input.h" - -char *getstring(char *fmt, ...) { - va_list args; - va_start(args, fmt); - - printf("? "); - vprintf(fmt, args); - putc(' ', stdout); - - va_end(args); - fflush(stdout); - - char *buf = NULL; - size_t size = 0; - ssize_t len = getline(&buf, &size, stdin); - - if (len < 0) { - free(buf); - return NULL; - } - - if (len > 0 && buf[len - 1] == '\n') - buf[len - 1] = '\0'; - - return buf; -} - -int yesno(char *fmt, ...) { - char prompt[256]; - - va_list ap; - va_start(ap, fmt); - vsnprintf(prompt, sizeof prompt, fmt, ap); - va_end(ap); - - char buf[64]; - for (;;) { - fprintf(stderr, "? %s", prompt); - fputs(" (y/n) ", stdout); - fflush(stdout); - - if (!fgets(buf, sizeof buf, stdin)) - return 0; - - size_t i = 0; - while (buf[i] && isspace((unsigned char)buf[i])) - i++; - if (!buf[i]) - continue; - - char c = tolower((unsigned char)buf[i]); - if (c == 'y') - return 1; - if (c == 'n') - return 0; - } -} diff --git a/input.h b/input.h deleted file mode 100644 index e9c4154..0000000 --- a/input.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef INPUT_H_ -#define INPUT_H_ - -enum { TRUE, FALSE, GUARANTEE }; - -char *getstring(char *fmt, ...); -int yesno(char *fmt, ...); - -#endif /* INPUT_H_ */ diff --git a/main.c b/main.c deleted file mode 100644 index ce4392a..0000000 --- a/main.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * main.c - * - * yait/fSD 1.0 - * - * Copying policy: - * - * yait 1.0 can be copied and distributed freely for any - * non-commercial purposes. yait 1.0 can only be incorporated - * into commercial software with the permission of the current author. - * - * This file contains the main driving routine, and some handling - * for C/SH distinction. - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "edef.h" -#include "proj.h" -#include "shell.h" -#include "usage.h" -#include "version.h" - -void usage(int status) { - printf("Usage: %s filename\n", PROGRAM_NAME); - printf(" or: %s [options]\n\n", PROGRAM_NAME); - fputs(" -s enable shell creation mode\n", stdout); - fputs(" -S enable shell creation mode as a full project\n", stdout); - fputs(" --git initialize a git repository\n", stdout); - 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 shell_mode = 0; - char *package = NULL; - int carg; - - if (argc < 2) - die("not enough arguments"); - - if (argc == 2) { - if (strcmp(argv[1], "--help") == 0) - usage(EXIT_SUCCESS); - else if (strcmp(argv[1], "--version") == 0) { - version(); - exit(EXIT_SUCCESS); - } - } - - for (carg = 1; carg < argc; ++carg) { - if (argv[carg][0] == '-') { - if (argv[carg][1] == 's') - shell_mode = SINGLE; - else if (argv[carg][1] == 'S') - shell_mode = FULL; - else if (strcmp(argv[carg], "--git")) - git = 1; - else - die("unknown option"); - } else - package = argv[carg]; - } - - if (!package) - die("no package name provided"); - - if (shell_mode) - makeshell(package, shell_mode); - else - makeproj(package); - - return 0; -} diff --git a/proj.c b/proj.c deleted file mode 100644 index c3732f9..0000000 --- a/proj.c +++ /dev/null @@ -1,264 +0,0 @@ -/* proj.c - * - * The routines in this file generater an - * opinionated C project. - * - * written by vx-clutch - */ - -#include -#include -#include - -#include "estruct.h" -#include "wrapper.h" -#include "file.h" -#include "input.h" -#include "proj.h" -#include "usage.h" -#include "util.h" -#include "version.h" - -int makeproj(char *src) { - if (ffexist(src)) - die("%s already exists", src); - - fmkdir(src); - if (chdir(src)) - die("could not cd into %s", src); - - int year = getyear(); - char *author = getstring("Author"); - char *description = getstring("Description"); - - ffwrite("main.c", "\ -/*\n\ - * main.c\n\ - *\n\ - * %s/%s 1.0\n\ - *\n\ - * Copying policy\n\ - *\n\ - * %s 1.0 can be copied and distributed freely for any\n\ - * non-commercial purposes. %s 1.0 can only be incorporated\n\ - * into commercial software with the permission of the current author.\n\ - *\n\ - * This file contains the main driving routine.\n\ - *\n\ - */\n\ -\n\ -#include \n\ -#include \n\ -#include \n\ -\n\ -#include \"version.h\"\n\ -#include \"estruct.h\"\n\ -\n\ -void usage(int status)\n\ -{\n\ - printf(\"Usage: %%s REQUIRED POSITIONAL ARGUMENT\\n\", PROGRAM_NAME);\n\ - printf(\" or: %%s [options]\\n\\n\", PROGRAM_NAME);\n\ - fputs(\" --help display this help and exit\\n\", stdout);\n\ - fputs(\" --version output version information and exit\\n\", stdout);\n\ -\n\ - exit(status);\n\ -}\n\ -\n\ -int main(int argc, char **argv)\n\ -{\n\ - int carg;\n\ -\n\ - if (argc == 2) {\n\ - if (strcmp(argv[1], \"--help\") == 0) {\n\ - usage(EXIT_FAILURE);\n\ - }\n\ - if (strcmp(argv[1], \"--version\") == 0) {\n\ - version();\n\ - exit(EXIT_SUCCESS);\n\ - }\n\ - }\n\ -\n\ - puts(MESSAGE);\n\ -\n\ - return 0;\n\ -}", src, author, src, src); - - size_t len = strlen(src) + 1 + strlen(author) + 6; /* account for " 1.0 " */ - char *pad = xmalloc(len + 1); - memset(pad, '-', len); - pad[len] = '\0'; - ffwrite("README", "\ -+%s+\n\ -| %s/%s 1.0 |\n\ -+%s+\n\ -\n\ - %s\n\ -\n\ - %s was written by %s\n\ -\n\ - Copyright Notices:\n\ -\n\ - %s 1.0 (c) Copyright %d %s\n\ -\n\ - Reference the COPYING file for detailed information\n\ -\n\ -\n\ -WHAT IS %s/%s?\n\ -\n\ -%s/%s 1.0 %s\n\ -\n\ -\n\ -WHAT IS NEW\n\ -\n\ -Features:\n\ -\n\ -o This is the first version, EVERYTHING is new!\n\ -\n\ -Bug fixes - not very interesting:\n\ -\n\ -o None\n\ -\n\ -Something is gone:\n\ -\n\ -o None\n\ -\n\ -HOW TO INSTALL %s/%s?\n\ -\n\ -o UNIX: Look at estruct.h, do a 'make', test the program, 'make install'.\n\ -\n\ -\n\ -ACKNOWLEDGEMENTS AND STATUS\n\ -\n\ -This project's file strucutre, file format, and certain contents are\n\ -derived from uEmacs/PK 4.0 specifically from the Linux Torvalds\n\ -distribution on GitHub. The README on from uEmacs/PK 4.0 has greater and\n\ -more accurate attributions, if you desire.\n\ -\n\ -%s was generated using %s %s\n\ -\n\ -LAST MODIFED DATE\ -", - pad, - src, author, - pad, - description, - src, author, - src, year, author, - src, author, - src, author, description, - src, author, - src, PROGRAM_NAME_LONG, VERSION); - - ffwrite("version.h", "\ -#ifndef VERSION_H_\n\ -#define VERSION_H_\n\ -\n\ -#define PROGRAM_NAME \"%s\"\n\ -#define PROGRAM_NAME_LONG \"%s/%s\"\n\ -\n\ -#define VERSION \"1.0.0\"\n\ -\n\ -/* Print the version string. */\n\ -void version(void);\n\ -\n\ -#endif /* VERSION_H_ */", src, src, author); - ffwrite("version.c", "\ -#include \n\ -#include \"version.h\"\n\ -\n\ -void version(void)\n\ -{\n\ - printf(\"%%s version %%s\\n\", PROGRAM_NAME_LONG, VERSION);\n\ -}"); - - ffwrite("Makefile", "\ -# Makefile for %s\n\ -\n\ -# Make the build silent by default\n\ -V =\n\ -\n\ -ifeq ($(strip $(V)),)\n\ - E = @echo\n\ - Q = @\n\ -else\n\ - E = @\\#\n\ - Q =\n\ -endif\n\ -export E Q\n\ -\n\ -PROGRAM = %s\n\ -TARBALL = $(PROGRAM).tar\n\ -SRC = $(wildcard *.c)\n\ -OBJ = $(SRC:.c=.o)\n\ -HDR = $(wildcard *.h)\n\ -\n\ -CC = gcc\n\ -WARNINGS = -Wall -Wstrict-prototypes\n\ -CFLAGS = -O2 $(WARNINGS) -g\n\ -DEFINES =\n\ -LIBS =\n\ -LDFLAGS =\n\ -BINDIR = /usr/bin\n\ -LIBDIR = /usr/lib\n\ -\n\ -$(PROGRAM): $(OBJ) $(HDR)\n\ - $(E) \" LINK \" $@\n\ - $(Q) $(CC) $(LDFLAGS) $(DEFINES) -o $@ $(OBJ) $(LIBS)\n\ -\n\ -clean:\n\ - $(E) \" CLEAN\"\n\ - $(Q) rm -f $(PROGRAM) $(OBJ)\n\ -\n\ -install: $(PROGRAM)\n\ - cp $(PROGRAM) ${BINDIR}\n\ -\n\ -release: $(PROGRAM)\n\ - tar cvf $(TARBALL) $(SRC) $(HDR) Makefile README\n\ -\n\ -.c.o:\n\ - $(E) \" CC \" $@\n\ - $(Q) $(CC) $(CFLAGS) $(DEFINES) -c $< -o $@", src, src); - - ffwrite("usage.h", "\ -#ifndef USAGE_H_\n\ -#define USAGE_H_\n\ -\n\ -void die(const char* err, ...);\n\ -\n\ -#endif /* USAGE_H_ */"); - ffwrite("usage.c", "\ -#include \"usage.h\"\n\ -\n\ -#include \n\ -#include \n\ -#include \n\ -\n\ -static void report(const char* prefix, const char *err, va_list params)\n\ -{\n\ - char msg[4096];\n\ - vsnprintf(msg, sizeof(msg), err, params);\n\ - fprintf(stderr, \"%%s%%s\\n\", prefix, msg);\n\ -}\n\ -\n\ -void die(const char* err, ...)\n\ -{\n\ - va_list params;\n\ -\n\ - va_start(params, err);\n\ - report(\"fatal: \", err, params);\n\ - va_end(params);\n\ - exit(128);\n\ -}"); - - ffwrite("estruct.h", "\ -#ifndef ESTRUCT_H_\n\ -#define ESTRUCT_H_\n\ -\n\ -/* Configuration options */\n\ -\n\ -#define MESSAGE \"Hello, World!\" /* Default greeting */\n\ -\n\ -#endif /* ESTRUCT_H_ */"); - - return 0; -} diff --git a/proj.h b/proj.h deleted file mode 100644 index 70a996e..0000000 --- a/proj.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef PROJ_H_ -#define PROJ_H_ - -int makeproj(char *src); - -#endif /* PROJ_H_ */ diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit new file mode 100644 index 0000000..038c17d --- /dev/null +++ b/scripts/git-hooks/pre-commit @@ -0,0 +1,16 @@ +#! /bin/sh +# +# Run pre commit checks on bin/yait. Requires `shellcheck` as well as a POSIX +# shell (duh) + +script_path="./bin/yait" + +if git diff --cached --name-only | grep -q "$script_path"; then + if ! shellcheck "$script_path"; then + echo "[$0]: Syntax errors found in $script_path. Commit aborted." + exit 1 + fi +fi + +echo "[$0] All Tests Pass" +exit 0 diff --git a/shell.c b/shell.c deleted file mode 100644 index a503e7f..0000000 --- a/shell.c +++ /dev/null @@ -1,77 +0,0 @@ -/* shell.c - * - * The routines in this file generater an - * opiionated shell script. - * - * written by vx-clutch - */ - -#include -#include - -#include "estruct.h" -#include "file.h" -#include "full.h" -#include "edef.h" -#include "input.h" -#include "shell.h" -#include "single.h" -#include "usage.h" - -int makeshell(char *src, int complexity) { - char *license = LICENSE; - - if (complexity == SINGLE) - single_init(src); - else if (complexity == FULL) { - full_project_init_and_cd(src); - } - else - die("invalid state! shell.c:%d", __LINE__); - - if (!QLICENSE) - license = getstring("License"); - char *description = getstring("Description"); - - ffwrite(src, "\ -#!/bin/sh\n\ -# SPDX-License-Identifier: %s\n\ -#\n\ -# %s\n\ -\n\ -me=$0\n\ -scriptversion=\"1.0.0\"\n\ -\n\ -version=\"$me $scriptversion\n\ -\n\ -Copyright (C) %d %s.\n\ -This is free software; you are free to change and redistribute it.\n\ -There is NO WARRANTY, to the extent permitted by law.\"\n\ -\n\ -usage=\"\\\n\ -Usage: $me [OPTION]...\n\ -%s\n\ -\n\ -Options:\n\ - --help print this help and exit\n\ - --version output version information\n\"\n\ -\n\ -while [ $# -gt 0 ]; do\n\ - case $1 in\n\ - --help) echo \"$usage\"; exit 0 ;;\n\ - --version) echo \"$version\"; exit 0 ;;\n\ - -*)\n\ - echo \"$0: Unknown option '$1'.\" >&2\n\ - echo \"$0: Try '--help' for more information.\" >&2\n\ - exit 1 ;;\n\ - esac\n\ - shift\n\ -done", - license, description, 2026, "fSD", description); - - struct stat st; - if (stat(src, &st) == 0) - chmod(src, st.st_mode | S_IXUSR | S_IXGRP | S_IXOTH); - - return 0; -} diff --git a/shell.h b/shell.h deleted file mode 100644 index c75a1aa..0000000 --- a/shell.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef SHELL_H_ -#define SHELL_H_ - -int makeshell(char *src, int complexity); - -#endif /* SHELL_H_ */ diff --git a/single.c b/single.c deleted file mode 100644 index 82706b0..0000000 --- a/single.c +++ /dev/null @@ -1,20 +0,0 @@ -/* single.c - * - * Init to be called before single file - * creation as a final product. - * - * written by vx-clutch - */ - -#include - -#include "file.h" -#include "single.h" -#include "usage.h" - -int single_init(char *src) -{ - if (ffexist(src)) - die("%s already exists", src); - return 0; -} diff --git a/single.h b/single.h deleted file mode 100644 index e7795dd..0000000 --- a/single.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef SINGLE_H_ -#define SINGLE_H_ - -int single_init(char *src); - -#endif /* SINGLE_H_ */ diff --git a/usage.c b/usage.c deleted file mode 100644 index 2d33500..0000000 --- a/usage.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "usage.h" - -#include -#include -#include - -static void report(const char* prefix, const char *err, va_list params) -{ - char msg[4096]; - vsnprintf(msg, sizeof(msg), err, params); - fprintf(stderr, "%s%s\n", prefix, msg); -} - -void die(const char* err, ...) -{ - va_list params; - - va_start(params, err); - report("fatal: ", err, params); - va_end(params); - exit(128); -} diff --git a/usage.h b/usage.h deleted file mode 100644 index ba78993..0000000 --- a/usage.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef USAGE_H_ -#define USAGE_H_ - -void die(const char* err, ...); - -#endif /* USAGE_H_ */ diff --git a/util.c b/util.c deleted file mode 100644 index 26a0795..0000000 --- a/util.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "util.h" -#include - -int getyear() -{ - time_t now = time(NULL); - struct tm *t = localtime(&now); - - return t->tm_year + 1900; -} diff --git a/util.h b/util.h deleted file mode 100644 index 58b59f8..0000000 --- a/util.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef UTIL_H_ -#define UTIL_H_ - -int getyear(); - -#endif diff --git a/version.c b/version.c deleted file mode 100644 index d974764..0000000 --- a/version.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "version.h" - -void version(void) -{ - printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION); -} diff --git a/version.h b/version.h deleted file mode 100644 index 800c888..0000000 --- a/version.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef VERSION_H_ -#define VERSION_H_ - -#define PROGRAM_NAME "yait" -#define PROGRAM_NAME_LONG "yait/fSD" - -#define VERSION "1.0.0" - -/* Print the version string. */ -void version(void); - -#endif /* VERSION_H_ */ diff --git a/wrapper.c b/wrapper.c deleted file mode 100644 index 288874e..0000000 --- a/wrapper.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -#include "wrapper.h" -#include "usage.h" - -void *xmalloc(size_t size) -{ - void *ret = malloc(size); - if (!ret) - die("memory exhausted"); - return ret; -} diff --git a/wrapper.h b/wrapper.h deleted file mode 100644 index 1ca0735..0000000 --- a/wrapper.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef WRAPPER_H_ -#define WRAPPER_H_ - -#include - -void *xmalloc(size_t size); - -#endif diff --git a/yait.1 b/yait.1 new file mode 100644 index 0000000..e69de29 From 5eb479589efc06752f5febfafb160809c31c01ad Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Thu, 8 Jan 2026 16:11:57 +0000 Subject: [PATCH 02/20] Inital branch commit --- scripts/git-hooks/pre-commit | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/git-hooks/pre-commit diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit old mode 100644 new mode 100755 From 852b590567b71c66e6853a24c738a2523559e842 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Thu, 8 Jan 2026 17:18:53 +0000 Subject: [PATCH 03/20] update pre-commit --- scripts/git-hooks/pre-commit | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit index 038c17d..5068bd6 100755 --- a/scripts/git-hooks/pre-commit +++ b/scripts/git-hooks/pre-commit @@ -1,16 +1,24 @@ -#! /bin/sh +#!/bin/sh # -# Run pre commit checks on bin/yait. Requires `shellcheck` as well as a POSIX -# shell (duh) +# Run pre-commit checks on bin/yait. Requires `shellcheck` and a POSIX +# shell (duh). + +me=$(basename "$0") + +fmt() { + echo "${me}[$$]: $*" +} script_path="./bin/yait" if git diff --cached --name-only | grep -q "$script_path"; then - if ! shellcheck "$script_path"; then - echo "[$0]: Syntax errors found in $script_path. Commit aborted." - exit 1 - fi + if shellcheck --enable=all --shell=sh "$script_path"; then + fmt "All tests passed." + exit 0 + else + fmt "Syntax errors found in $script_path. Commit aborted." + exit 1 + fi fi -echo "[$0] All Tests Pass" exit 0 From 15270f6938be93563066fb97381345d08283b773 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Thu, 8 Jan 2026 17:19:01 +0000 Subject: [PATCH 04/20] redo README --- README | 51 --------------------------------------------------- README.md | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 51 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index 580abd2..0000000 --- a/README +++ /dev/null @@ -1,51 +0,0 @@ -+--------------+ -| yait/fSD 1.0 | -+--------------+ - - Highly opinionated C and SH project generator - - yait was written by vx-clutch - - Copyright Notices: - - yait 1.0 (c) Copyright 2025-2026 fSD. - - Reference the COPYING file for detailed information - - -WHAT IS yait/fSD? - -yait/fSD 1.0 is an optionated C and SH project generator. For C project -generation is produces a similar layout to the source of this project. On -SH it generates a shell script with useful scaffolding for a script. For -more detailed useage compile the program for your system and run with the -`--help` option. - - -WHAT IS NEW - -Features: - -o This is the first version, EVERYTHING is new! - -Bug fixes - not very interesting: - -o None - -Something is gone: - -o None - -HOW TO INSTALL yait/fSD? - -o UNIX: Look at estruct.h, do a 'make', test the program, 'make install'. - - -ACKNOWLEDGEMENTS AND STATUS - -This project's file strucutre, file format, and certain contents are -derived from uEmacs/PK 4.0 specifically from the Linux Torvalds -distribution on GitHub. The README on from uEmacs/PK 4.0 has greater and -more accurate attributions, if you desire. - -November 12, 2025 diff --git a/README.md b/README.md new file mode 100644 index 0000000..451a6a7 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# yait + +https://fsd.vxserver.dev/releases/yait + +Get your project started: + +- A full C or SH project template +- Extensible file templating + * via ~/.local/share/yait/templates + +## Install + +#### Dependencies + +- `shellcheck` - lint shell scripts **development dependency** + +**Note**: `shellcheck` is used as a pre-commit git hook to for quality +assurance purposes. This does not invalidate our COPYING policy. This software +still should be used at your own risk without an warranty + +```bash +git clone https://git.vxserver.dev/fSD/yait +cd yait +sudo make install +``` + +## Usage + +This tool runs via the command `yait`. + +- `yait -x c` -- Create a C project. +- `yait -x sh` -- Create a SH project. +- `yait -S ...` -- Create a single/small project. +- `yait -f` -- Overwrite existing files. From 1be39bd69f93f3d0d385fc462d94f6b0218950cd Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Sun, 11 Jan 2026 19:29:59 -0500 Subject: [PATCH 05/20] template files --- 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 ++++++++++++++++++++++++++ 5 files changed, 251 insertions(+) create mode 100644 t/default/c.stpl create mode 100644 t/default/ignore.stpl create mode 100644 t/default/makefile.stpl create mode 100644 t/default/readme.stpl create mode 100644 t/default/sh.stpl diff --git a/t/default/c.stpl b/t/default/c.stpl new file mode 100644 index 0000000..ecda0ae --- /dev/null +++ b/t/default/c.stpl @@ -0,0 +1,78 @@ +; 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 new file mode 100644 index 0000000..d37d694 --- /dev/null +++ b/t/default/ignore.stpl @@ -0,0 +1,12 @@ +; 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 new file mode 100644 index 0000000..6c7bc27 --- /dev/null +++ b/t/default/makefile.stpl @@ -0,0 +1,64 @@ +; 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 new file mode 100644 index 0000000..6b21e48 --- /dev/null +++ b/t/default/readme.stpl @@ -0,0 +1,48 @@ +; 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 new file mode 100644 index 0000000..cf1271f --- /dev/null +++ b/t/default/sh.stpl @@ -0,0 +1,49 @@ +; 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 From 29fdadafdbb7ef57306baa537f8730624b2ac640 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Sun, 11 Jan 2026 19:30:22 -0500 Subject: [PATCH 06/20] install templates and manual pages with Makefile --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index c00aabf..4318b37 100644 --- a/Makefile +++ b/Makefile @@ -3,3 +3,12 @@ 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 From 295713440dd1b3c12bfce4564cd603e77d879811 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Sun, 11 Jan 2026 19:30:30 -0500 Subject: [PATCH 07/20] manual page --- yait.1 | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/yait.1 b/yait.1 index e69de29..d1da971 100644 --- a/yait.1 +++ b/yait.1 @@ -0,0 +1,42 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. +.TH YAIT "1" "January 2026" "yait v1" "User Commands" +.SH NAME +yait \- manual page for yait v1 +.SH SYNOPSIS +.B yait +[\fI\,OPTION\/\fR]... \fI\, \/\fR +.SH DESCRIPTION +Highly opinionated C and SH project generator +.SH OPTIONS +.TP +\fB\-\-help\fR +print this help and exit +.TP +\fB\-\-version\fR +output version information +.TP +\fB\-x\fR +set project type +.TP +\fB\-S\fR +small project creation +.TP +\fB\-f\fR +overwrite existing files +.TP +\fB\-n\fR +set project name +.TP +\fB\-a\fR +set project author +.TP +\fB\-r\fR +initialize Git repository for the project +.TP +\fB\-q\fR +surpress output +.SH COPYRIGHT +Copyright \(co 2025\-2026 fSD. +.br +This is free software; you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. From fd7ac4dd7a64b4adf74b8ff3fdf669775b76821b Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Mon, 12 Jan 2026 10:32:16 -0500 Subject: [PATCH 08/20] update gitignore because it hide the main program --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 76be36b..4c64d94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -yait -*.o +/stuff/ +*.tar.gz \ No newline at end of file From e175ee2730c49a1f55655c2f302f950125408555 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Mon, 12 Jan 2026 16:41:17 -0500 Subject: [PATCH 09/20] commit script after mishap --- bin/yait | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 bin/yait diff --git a/bin/yait b/bin/yait new file mode 100755 index 0000000..bf86f45 --- /dev/null +++ b/bin/yait @@ -0,0 +1,81 @@ +#! /bin/sh +# Highly opinionated C and SH project generator + +scriptversion="1" + +# +# +# Copyright (C) 2025-2026 vx-clutch +# 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. + +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 + +Copyright (C) 2025-2026 fSD. +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]... +Highly opinionated C and SH project generator + +Options: + --help print this help and exit + --version output version information + + -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= + +mfmt() { + if [ -z "$q" ]; then + echo "$me: $*" + fi +} + +while [ $# -gt 0 ]; do + case $1 in + --help) echo "$usage"; exit 0 ;; + --version) echo "$version"; exit 0 ;; + -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 ;; + esac +done + +if ! [ $# -gt 0 ]; then + echo "$usage" + exit 0 +fi From 3c36fc3963a39c58c9a2c21f1e746ced645993dd Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Mon, 12 Jan 2026 17:05:34 -0500 Subject: [PATCH 10/20] 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 From 4a0c8dd0c67314a4949adaff478e118aeb27c2c3 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Mon, 12 Jan 2026 18:29:29 -0500 Subject: [PATCH 11/20] correct copyright and add small shell --- bin/yait | 128 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 108 insertions(+), 20 deletions(-) diff --git a/bin/yait b/bin/yait index 32cc64f..84159f0 100755 --- a/bin/yait +++ b/bin/yait @@ -5,15 +5,15 @@ scriptversion="1" # # -# Copyright (C) 2025-2026 vx-clutch +# Copyright (C) 2025-2026 fSD # 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 +me=$(basename "$0") +version="$me\/fSD v$scriptversion Copyright (C) 2025-2026 fSD. This is free software; you are free to change and redistribute it. @@ -27,35 +27,122 @@ Options: --help print this help and exit --version output version information - -x set project type - -S small project creation - -f overwrite existing files - -a set project author - -r initialize Git repository for the project - -q surpress output" + -x set project type + -d set a description + -S small project creation + -f overwrite existing files + -a set project author + -r initialize Git repository for the project + -q surpress output" -x=C # language +x=c # language +d="Does a thing" # package description S= # small project creation (bool) f= # force (bool) a=$(git config user.name) # author r= # initialize repository (bool) q= # surpress output -format() { +say() { if [ -z "$q" ]; then echo "$me: $*" fi } +lsay() { + if [ -z "$q" ]; then + echo " => $*" + fi +} + create_project() { name=$1 if ! echo "$name" | grep -qE '^[A-Za-z0-9_-]+$'; then - format "invalid name '$name'" + say "invalid name '$name'" exit 1 fi - echo "invoke" + shell() { + if [ -z "$S" ]; then + mkdir "$name" || return + cd "$name" || return + + touch COPYING Makefile README.md "$name.1" .gitignore + mkdir bin + else + cat < "$name" +#! /bin/sh +# $d + +scriptversion="1" + +# +# +# Copyright (C) $(date "+%Y") $a +# 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/$a v\$scriptversion + +Copyright (C) $(date "+%Y") $a. +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]... +$d + +Options: + --help print this help and exit + --version output version information" + +say() { + if [ -z "\$q" ]; then + echo "\$me: \$*" + fi +} + +lsay() { + if [ -z "\$q" ]; then + echo " => \$*" + fi +} + +if ! [ \$# -gt 0 ]; then + echo "\$usage" + exit 0 +fi + +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 ;; + esac +done + +say hello world +EOF + chmod +x "$name" + fi + } + + c() { + lsay "sub routine: c" + } + + case $x in + sh) say "using shell"; shell ;; + c) say "using C"; c ;; + *) say "defaulting to C"; c ;; + esac + + say "made $name at $(realpath "$name")" } if ! [ $# -gt 0 ]; then @@ -67,13 +154,14 @@ while [ $# -gt 0 ]; do case $1 in --help) echo "$usage"; exit 0 ;; --version) echo "$version"; exit 0 ;; - -x) shift; x=$1; break ;; - -S) S=true; break ;; - -f) f=true; break ;; - -a) shift; a=$1; break ;; - -r) r=true; break ;; - -q) q=true; break ;; + -x) shift; x="$1"; shift ;; + -d) shift; d="$1"; shift ;; + -S) S=true; shift ;; + -f) f=true; shift ;; + -a) shift; a="$1"; shift ;; + -r) r=true; shift ;; + -q) q=true; shift ;; -*) echo "$me: Unknown option '$1'." >&2; exit 1 ;; - *) create_project $1; shift ;; + *) create_project "$1"; shift ;; esac done From 09b899d342229358c78c544c7bbdeef72dc91538 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Tue, 13 Jan 2026 19:00:58 -0500 Subject: [PATCH 12/20] move license --- COPYING => LICENSE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename COPYING => LICENSE (100%) diff --git a/COPYING b/LICENSE similarity index 100% rename from COPYING rename to LICENSE From 26b3cb41a307e4e096d2869b6de475224f6ee825 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Tue, 13 Jan 2026 19:01:03 -0500 Subject: [PATCH 13/20] add dep --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 451a6a7..40516d1 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Get your project started: #### Dependencies +- `git` - source control tool - `shellcheck` - lint shell scripts **development dependency** **Note**: `shellcheck` is used as a pre-commit git hook to for quality From b3a7d03fcdfbf0469814883a95dac26276929294 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Tue, 13 Jan 2026 19:04:23 -0500 Subject: [PATCH 14/20] yait 0.0.1 --- bin/yait | 305 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 294 insertions(+), 11 deletions(-) diff --git a/bin/yait b/bin/yait index 84159f0..e450087 100755 --- a/bin/yait +++ b/bin/yait @@ -1,7 +1,7 @@ #! /bin/sh # Highly opinionated C and SH project generator -scriptversion="1" +scriptversion="0.0.1" # # @@ -64,14 +64,78 @@ create_project() { fi shell() { + outfile="$name" + if [ -z "$S" ]; then mkdir "$name" || return cd "$name" || return - touch COPYING Makefile README.md "$name.1" .gitignore - mkdir bin - else - cat < "$name" + cat < LICENSE +ISC License + +Copyright (c) $(date "+%Y") $a + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +EOF + cat < Makefile +all: + @echo "nothing to do" + +install: + cp bin/$name /usr/local/bin + cp $name.1 /usr/local/share/man/man1/$name.1 + chmod 644 /usr/local/share/man/man1/$name.1 + +uninstall: + \$(RM) /usr/local/bin/$name + \$(RM) /usr/local/share/man/man1/$name.1 +EOF + cat < README.md +# $name + +YOUR_WEBSITE + +$d: + +- Feature 1 +- Feature 2 + * feature 2a + +## Install + +#### Dependencies + +- \`fzf\` - terminal fuzzy finder + +**Note**: \`fzf\` is used as an example dependency + +\`\`\`bash +git clone YOUR_REPO_URL +cd $name +sudo make install +\`\`\` + +## Usage + +This tool runs via the command \`$name\`. + +- \`$name -k\` -- Does option k +EOF + + mkdir bin || return + outfile="bin/$outfile" + fi + cat < "$outfile" #! /bin/sh # $d @@ -128,21 +192,240 @@ done say hello world EOF - chmod +x "$name" - fi + chmod +x "$outfile" } c() { - lsay "sub routine: c" + mkdir "$name" || return + cd "$name" || return + cat < README +$name +$(echo "$name" | sed 's/./=/g') +$d + + +Requirements +------------ +In order to build $name you need the LIBRARY header files. + + +Instillation +------------ +Edit config.mk to match your local setup ($name is installed into +the /usr/local namesapce by default). + +Afterwards enter the following command to build and install $name (if +necessary as root): + + make clean install + +Running $name +$(echo "Running $name" | sed 's/./=/g') +To run $name use the following command: + + ./$name + +Configuration +------------- +The configuration of $name is done by creating a custom config.h +and (re)compiling the source code. +EOF + cat < LICENSE +ISC License + +Copyright (c) $(date "+%Y") $a + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +EOF + cat < Makefile +# $name +# See LICENSE file for copyright and license details. + +include config.mk + +SRC = $name.c +OBJ = \${SRC:.c=.o} + +all: $name + +.c.o: + \${CC} -c \${CFLAGS} \$< + +\${OBJ}: config.h config.mk + +config.h: + cp config.def.h \$@ + +dwm: \${OBJ} + \${CC} -o \$@ \${OBJ} \${LDFLAGS} + +clean: + rm -f $name \${OBJ} $name-\${VERSION}.tar.gz + +dist: clean + mkdir -p $name-\${VERSION} + cp -R LICENSE Makefile README config.def.h config.mk\ + $name.1 \${SRC} $name-\${VERSION} + tar -cf $name-\${VERSION}.tar $name-\${VERSION} + gzip $name-\${VERSION}.tar + rm -rf $name-\${VERSION} + +install: all + mkdir -p \${DESTDIR}\${PREFIX}/bin + cp -f $name \${DESTDIR}\${PREFIX}/bin + chmod 755 \${DESTDIR}\${PREFIX}/bin/$name + mkdir -p \${DESTDIR}\${MANPREFIX}/man1 + sed "s/VERSION/\${VERSION}/g" < $name.1 > \${DESTDIR}\${MANPREFIX}/man1/$name.1 + chmod 644 \${DESTDIR}\${MANPREFIX}/man1/$name.1 + +uninstall: + rm -f \${DESTDIR}\${PREFIX}/bin/$name\ + \${DESTDIR}\${MANPREFIX}/man1/$name.1 + +.PHONY: all clean dist install uninstall +EOF + cat < config.def.h +/* See LICENSE file for copyright and license details. */ +EOF + cat < config.mk +# $name version +VERSION = 0.1 + +# Customize below to fit your system + +# paths +PREFIX = /usr/local +MANPREFIX = \${PREFIX}/share/man + +# includes and libs +INCS = +LIBS = + +# flags +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"\${VERSION}\" +CFLAGS = -g -std=c99 -pedantic -Wall -O0 \${INCS} \${CPPFLAGS} +CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os \${INCS} \${CPPFLAGS} +LDFLAGS = \${LIBS} + +# compiler and linker +CC = cc +EOF + cat < arg.h +/* + * Copy me if you can. + * by 20h + */ + +#ifndef ARG_H__ +#define ARG_H__ + +extern char *argv0; + +/* use main(int argc, char *argv[]) */ +#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ + argv[0] && argv[0][1]\\ + && argv[0][0] == '-';\\ + argc--, argv++) {\\ + char argc_;\\ + char **argv_;\\ + int brk_;\\ + if (argv[0][1] == '-' && argv[0][2] == '\\0') {\\ + argv++;\\ + argc--;\\ + break;\\ + }\\ + for (brk_ = 0, argv[0]++, argv_ = argv;\\ + argv[0][0] && !brk_;\\ + argv[0]++) {\\ + if (argv_ != argv)\\ + break;\\ + argc_ = argv[0][0];\\ + switch (argc_) + +/* Handles obsolete -NUM syntax */ +#define ARGNUM case '0':\\ + case '1':\\ + case '2':\\ + case '3':\\ + case '4':\\ + case '5':\\ + case '6':\\ + case '7':\\ + case '8':\\ + case '9' + +#define ARGEND }\\ + } + +#define ARGC() argc_ + +#define ARGNUMF(base) (brk_ = 1, estrtol(argv[0], (base))) + +#define EARGF(x) ((argv[0][1] == '\\0' && argv[1] == NULL)?\\ + ((x), abort(), (char *)0) :\\ + (brk_ = 1, (argv[0][1] != '\\0')?\\ + (&argv[0][1]) :\\ + (argc--, argv++, argv[0]))) + +#define ARGF() ((argv[0][1] == '\\0' && argv[1] == NULL)?\\ + (char *)0 :\\ + (brk_ = 1, (argv[0][1] != '\\0')?\\ + (&argv[0][1]) :\\ + (argc--, argv++, argv[0]))) + +#endif +EOF + cat < "$name.c" +/* See LICENSE file for license details. */ +#include +#include + +#include "arg.h" +#include "config.h" + +char *argv0; + +static void +usage(void) { + fprintf(stderr, "%s: usage: $name [-v]\\n", argv0); + exit(1); +} + +int +main(int argc, char *argv[]) { + + ARGBEGIN { + case 'v': + printf("$name/$a version %s\\n", VERSION); + exit(0); + default: + usage(); + } ARGEND; + + puts("Hello, World!"); + + return 0; +} +EOF } case $x in - sh) say "using shell"; shell ;; - c) say "using C"; c ;; - *) say "defaulting to C"; c ;; + sh) shell ;; + *) c ;; esac say "made $name at $(realpath "$name")" + cd .. } if ! [ $# -gt 0 ]; then From bbc8030dfb6477407da901cf4022de24b3c9f10f Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Tue, 13 Jan 2026 20:10:30 -0500 Subject: [PATCH 15/20] add git integration --- bin/yait | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/yait b/bin/yait index e450087..59a0048 100755 --- a/bin/yait +++ b/bin/yait @@ -4,9 +4,7 @@ scriptversion="0.0.1" # -# -# Copyright (C) 2025-2026 fSD -# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# Copyright (C) 2025-2026 fSD 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 @@ -424,6 +422,10 @@ EOF *) c ;; esac + if ! [ -z "$r" ]; then + git init -q || echo "$me: could not initilzie git repository" >&2 + fi + say "made $name at $(realpath "$name")" cd .. } From b54989f0eeca1b73412c42149b1730aac964e3fb Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Tue, 13 Jan 2026 20:10:44 -0500 Subject: [PATCH 16/20] fix version --- bin/yait | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/yait b/bin/yait index 59a0048..aadb1a9 100755 --- a/bin/yait +++ b/bin/yait @@ -1,7 +1,7 @@ #! /bin/sh # Highly opinionated C and SH project generator -scriptversion="0.0.1" +scriptversion="0.1.0" # # Copyright (C) 2025-2026 fSD THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR From 12e838c0f066d4f8bb8d9df7f0de50787c48b86f Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Tue, 13 Jan 2026 20:11:19 -0500 Subject: [PATCH 17/20] fix version format --- bin/yait | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/yait b/bin/yait index aadb1a9..e3c7161 100755 --- a/bin/yait +++ b/bin/yait @@ -11,7 +11,7 @@ scriptversion="0.1.0" # SOFTWARE. me=$(basename "$0") -version="$me\/fSD v$scriptversion +version="$me/fSD v$scriptversion Copyright (C) 2025-2026 fSD. This is free software; you are free to change and redistribute it. From a4f455deec79403be980b422feaba046b06b2bd0 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Wed, 14 Jan 2026 09:12:58 -0500 Subject: [PATCH 18/20] [patch] change format of the git init error --- bin/yait | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/yait b/bin/yait index e3c7161..837ea06 100755 --- a/bin/yait +++ b/bin/yait @@ -1,7 +1,7 @@ #! /bin/sh # Highly opinionated C and SH project generator -scriptversion="0.1.0" +scriptversion="0.1.1" # # Copyright (C) 2025-2026 fSD THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR @@ -423,7 +423,7 @@ EOF esac if ! [ -z "$r" ]; then - git init -q || echo "$me: could not initilzie git repository" >&2 + git init -q || echo "$me: error: could not initilzie git repository" >&2 fi say "made $name at $(realpath "$name")" From deca2349cf2e77f48d907efd42f6db42a90f3569 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Wed, 14 Jan 2026 13:54:35 -0500 Subject: [PATCH 19/20] implement -f --- bin/yait | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/bin/yait b/bin/yait index 837ea06..6e7635e 100755 --- a/bin/yait +++ b/bin/yait @@ -1,7 +1,7 @@ #! /bin/sh # Highly opinionated C and SH project generator -scriptversion="0.1.1" +scriptversion="0.2.1" # # Copyright (C) 2025-2026 fSD THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR @@ -65,8 +65,14 @@ create_project() { outfile="$name" if [ -z "$S" ]; then - mkdir "$name" || return - cd "$name" || return + if [ -d "$name" ]; then + if ! [ -z "$f" ]; then + rm -rf "$name" + fi + fi + + mkdir "$name" || exit 1 + cd "$name" || exit 1 cat < LICENSE ISC License @@ -130,7 +136,7 @@ This tool runs via the command \`$name\`. - \`$name -k\` -- Does option k EOF - mkdir bin || return + mkdir bin || exit 1 outfile="bin/$outfile" fi cat < "$outfile" @@ -194,8 +200,13 @@ EOF } c() { - mkdir "$name" || return - cd "$name" || return + if [ -d "$name" ]; then + if ! [ -z "$f" ]; then + rm -rf "$name" + fi + fi + mkdir "$name" || exit 1 + cd "$name" || exit 1 cat < README $name $(echo "$name" | sed 's/./=/g') From 3073d4e88f839cfd7c002b6bea22ee4674623603 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Wed, 14 Jan 2026 20:29:23 -0500 Subject: [PATCH 20/20] update man page --- yait.1 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/yait.1 b/yait.1 index d1da971..bdcd89c 100644 --- a/yait.1 +++ b/yait.1 @@ -1,7 +1,7 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. -.TH YAIT "1" "January 2026" "yait v1" "User Commands" +.TH FSD "1" "January 2026" "fSD v0.2.1" "User Commands" .SH NAME -yait \- manual page for yait v1 +fSD \- manual page for fSD v0.2.1 .SH SYNOPSIS .B yait [\fI\,OPTION\/\fR]... \fI\, \/\fR @@ -17,6 +17,8 @@ output version information .TP \fB\-x\fR set project type +.HP +\fB\-d\fR set a description .TP \fB\-S\fR small project creation @@ -24,9 +26,6 @@ small project creation \fB\-f\fR overwrite existing files .TP -\fB\-n\fR -set project name -.TP \fB\-a\fR set project author .TP