From b3a7d03fcdfbf0469814883a95dac26276929294 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Tue, 13 Jan 2026 19:04:23 -0500 Subject: [PATCH] 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