Compare commits

...

34 Commits

Author SHA1 Message Date
cf5751840a fix spelling 2026-01-16 13:03:54 -05:00
5133045b31 add comments and remove left over from reference makefile 2026-01-14 21:51:55 -05:00
fc3d0a2e69 Merge pull request 'rewrite complete' (#1) from rewrite into main
Reviewed-on: #1
2026-01-14 20:39:14 -05:00
3073d4e88f update man page 2026-01-14 20:29:23 -05:00
deca2349cf implement -f 2026-01-14 13:54:35 -05:00
a4f455deec [patch] change format of the git init error 2026-01-14 09:12:58 -05:00
12e838c0f0 fix version format 2026-01-13 20:11:19 -05:00
b54989f0ee fix version 2026-01-13 20:10:44 -05:00
bbc8030dfb add git integration 2026-01-13 20:10:30 -05:00
b3a7d03fcd yait 0.0.1 2026-01-13 19:04:23 -05:00
26b3cb41a3 add dep 2026-01-13 19:01:03 -05:00
09b899d342 move license 2026-01-13 19:00:58 -05:00
4a0c8dd0c6 correct copyright and add small shell 2026-01-12 18:29:29 -05:00
3c36fc3963 remove template system 2026-01-12 17:05:34 -05:00
e175ee2730 commit script after mishap 2026-01-12 16:41:17 -05:00
fd7ac4dd7a update gitignore because it hide the main program 2026-01-12 10:32:16 -05:00
295713440d manual page 2026-01-11 19:30:30 -05:00
29fdadafdb install templates and manual pages with Makefile 2026-01-11 19:30:22 -05:00
1be39bd69f template files 2026-01-11 19:29:59 -05:00
15270f6938 redo README 2026-01-08 17:19:01 +00:00
852b590567 update pre-commit 2026-01-08 17:18:53 +00:00
5eb479589e Inital branch commit 2026-01-08 16:11:57 +00:00
82c7fbcb69 Inital branch commit 2026-01-08 16:09:43 +00:00
47e0690f4a new year bump 2025-12-31 13:09:29 -05:00
54db089b71 add weak git integration 2025-11-22 10:22:26 -05:00
fc2e477665 wip 2025-11-18 15:21:22 -05:00
82635759a7 wip 2025-11-13 21:34:44 -05:00
52c0d05889 wip 2025-11-13 15:27:28 -05:00
e42881c4d1 wip 2025-11-13 15:27:13 -05:00
vx_clutch
cd6cf9ff4f Fix typo and update date in README 2025-11-13 09:33:48 -05:00
6a50590393 wip 2025-11-12 22:09:34 -05:00
27c248c9bb add license 2025-11-12 18:33:26 -05:00
f764bc6759 wip 2025-11-11 21:49:23 -05:00
vx_clutch
22242dc532 Update README 2025-11-11 08:26:42 -05:00
27 changed files with 592 additions and 687 deletions

4
.gitignore vendored
View File

@@ -1,2 +1,2 @@
yait
*.o
/stuff/
*.tar.gz

15
LICENSE Normal file
View File

@@ -0,0 +1,15 @@
ISC License
Copyright (c) 2025-2026 fSD
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.

View File

@@ -1,46 +1,11 @@
# Makefile for yait
all:
@echo "nothing to do"
# Make the build silent by default
V =
install:
cp bin/yait /usr/local/bin
cp yait.1 /usr/local/share/man/man1/yait.1
chmod 644 /usr/local/share/man/man1/yait.1
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 $@
uninstall:
$(RM) /usr/local/bin/yait
$(RM) /usr/local/share/man/man1/yait.1

51
README
View File

@@ -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 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 inital commit, 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 11, 2025

35
README.md Normal file
View File

@@ -0,0 +1,35 @@
# 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
- `git` - source control tool
- `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.

466
bin/yait Executable file
View File

@@ -0,0 +1,466 @@
#! /bin/sh
# Highly opinionated C and SH project generator
scriptversion="0.3.1"
#
# 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=$(basename "$0")
version="$me/fSD 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]... <version> <dir>
Highly opinionated C and SH project generator
Options:
--help print this help and exit
--version output version information
-x <language> set project type
-d <description> set a description
-S small project creation
-f overwrite existing files
-a <author> set project author
-r initialize Git repository for the project
-q suppress output"
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
say() {
if [ -z "$q" ]; then
echo "$me: $*"
fi
}
lsay() {
if [ -z "$q" ]; then
echo " => $*"
fi
}
# main creation routine
create_project() {
name=$1
if ! echo "$name" | grep -qE '^[A-Za-z0-9_-]+$'; then
say "invalid name '$name'"
exit 1
fi
# creates a shell project
shell() {
outfile="$name"
if [ -z "$S" ]; then
if [ -d "$name" ]; then
if ! [ -z "$f" ]; then
rm -rf "$name"
fi
fi
mkdir "$name" || exit 1
cd "$name" || exit 1
cat <<EOF > 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 <<EOF > 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 <<EOF > 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 || exit 1
outfile="bin/$outfile"
fi
cat <<EOF > "$outfile"
#! /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]... <arg1> <arg2>
$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 "$outfile"
}
# creates a C project
c() {
if [ -d "$name" ]; then
if ! [ -z "$f" ]; then
rm -rf "$name"
fi
fi
mkdir "$name" || exit 1
cd "$name" || exit 1
cat <<EOF > 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 <<EOF > 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 <<EOF > 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 \$@
$name: \${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 <<EOF > config.def.h
/* See LICENSE file for copyright and license details. */
EOF
cat <<EOF > 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 <<EOF > 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 <<EOF > "$name.c"
/* See LICENSE file for license details. */
#include <stdio.h>
#include <stdlib.h>
#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) shell ;;
*) c ;;
esac
if ! [ -z "$r" ]; then
git init -q || echo "$me: error: could not initilzie git repository" >&2
fi
say "made $name at $(realpath "$name")"
cd ..
}
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 ;;
-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 ;;
esac
done

View File

@@ -1,12 +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*/
#endif /* ESTRUCT_H_ */

78
file.c
View File

@@ -1,78 +0,0 @@
/* file.c
*
* The routines in this file handle the reading, writing
* and lookup of disk files. All of details about the
* reading and writing of the disk are in "fileio.c".
*
* written by vx-clutch
*/
#include <errno.h>
#include <libgen.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "file.h"
#include "globals.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;
}

8
file.h
View File

@@ -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_ */

76
full.c
View File

@@ -1,76 +0,0 @@
/* full.c
*
* Init to be called before project creation.
*
* written by vx-clutch
*/
#include <unistd.h>
#include "file.h"
#include "full.h"
#include "usage.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 2025 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);
return 0;
}

6
full.h
View File

@@ -1,6 +0,0 @@
#ifndef FULL_H_
#define FULL_H_
int full_project_init_and_cd(char *src);
#endif /* FULL_H_ */

View File

@@ -1,14 +0,0 @@
/* globals.h
*
* Global definitions
*
* written by vx-clutch
*/
#ifndef GLOBALS_H_
#define GLOBALS_H_
enum { SINGLE = 1, FULL = 2 };
#define NPAT 4096 /* number of bytes for path buffer */
#endif /* GLOBALS_H_ */

70
input.c
View File

@@ -1,70 +0,0 @@
/* input.c
*
* Various input routines
*
* written by vx-clutch
*/
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#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 yes_no_prompt(const 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;
}
}

View File

@@ -1,9 +0,0 @@
#ifndef INPUT_H_
#define INPUT_H_
enum { TRUE, FALSE, GUARANTEE };
char *getstring(char *fmt, ...);
int mlyesno(char *fmt, ...);
#endif /* INPUT_H_ */

82
main.c
View File

@@ -1,82 +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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "globals.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(" -i ignore estruct.h and prompt for all\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 i = 0;
int shell_mode = 0;
char *package = NULL;
if (argc < 2)
die("not enough arguments");
for (int i = 1; i < argc; ++i)
{
if (argv[i][0] == '-')
{
if (strcmp(argv[i], "--help") == 0)
usage(EXIT_SUCCESS);
else if (strcmp(argv[i], "--version") == 0)
{
version();
exit(EXIT_SUCCESS);
}
else if (strcmp(argv[i], "-s") == 0)
shell_mode = SINGLE;
else if (strcmp(argv[i], "-S") == 0)
shell_mode = FULL;
else if (strcmp(argv[i], "-i") == 0)
i = 1;
else
die("unknown option");
}
else
package = argv[i];
}
if (!package)
die("no package name provided");
if (shell_mode)
makeshell(package, shell_mode);
else
makeproj(package);
return 0;
}

74
proj.c
View File

@@ -1,74 +0,0 @@
/* proj.c
*
* The routines in this file generater an
* opinionated C project.
*
* written by vx-clutch
*/
#include <unistd.h>
#include "estruct.h"
#include "file.h"
#include "input.h"
#include "proj.h"
#include "usage.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);
ffwrite("main.c", "\
/*\n\
* main.c\n\
*\n\
* package/Author 1.0\n\
*\n\
* Copying policy\n\
*\n\
* yait 1.0 can be copied and distributed freely for any\n\
* non-commercial purposes. yait 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 <stdio.h>\n\
#include <stdlib.h>\n\
#include <string.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\
return 0;\n\
}");
return 0;
}

6
proj.h
View File

@@ -1,6 +0,0 @@
#ifndef PROJ_H_
#define PROJ_H_
int makeproj(char *src);
#endif /* PROJ_H_ */

24
scripts/git-hooks/pre-commit Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/sh
#
# 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 --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
exit 0

76
shell.c
View File

@@ -1,76 +0,0 @@
/* shell.c
*
* The routines in this file generater an
* opiionated shell script.
*
* written by vx-clutch
*/
#include <sys/stat.h>
#include <sys/types.h>
#include "estruct.h"
#include "file.h"
#include "full.h"
#include "globals.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, 2025, "fSD", description);
struct stat st;
if (stat(src, &st) == 0)
chmod(src, st.st_mode | S_IXUSR | S_IXGRP | S_IXOTH);
return 0;
}

View File

@@ -1,6 +0,0 @@
#ifndef SHELL_H_
#define SHELL_H_
int makeshell(char *src, int complexity);
#endif /* SHELL_H_ */

View File

@@ -1,20 +0,0 @@
/* single.c
*
* Init to be called before single file
* creation as a final product.
*
* written by vx-clutch
*/
#include <unistd.h>
#include "file.h"
#include "single.h"
#include "usage.h"
int single_init(char *src)
{
if (ffexist(src))
die("%s already exists", src);
return 0;
}

View File

@@ -1,6 +0,0 @@
#ifndef SINGLE_H_
#define SINGLE_H_
int single_init(char *src);
#endif /* SINGLE_H_ */

22
usage.c
View File

@@ -1,22 +0,0 @@
#include "usage.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
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);
}

View File

@@ -1,6 +0,0 @@
#ifndef USAGE_H_
#define USAGE_H_
void die(const char* err, ...);
#endif /* USAGE_H_ */

View File

@@ -1,7 +0,0 @@
#include <stdio.h>
#include "version.h"
void version(void)
{
printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION);
}

View File

@@ -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_ */

41
yait.1 Normal file
View File

@@ -0,0 +1,41 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH FSD "1" "January 2026" "fSD v0.2.1" "User Commands"
.SH NAME
fSD \- manual page for fSD v0.2.1
.SH SYNOPSIS
.B yait
[\fI\,OPTION\/\fR]... \fI\,<version> <dir>\/\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 <language>
set project type
.HP
\fB\-d\fR <description> set a description
.TP
\fB\-S\fR
small project creation
.TP
\fB\-f\fR
overwrite existing files
.TP
\fB\-a\fR <author>
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.