rewrite complete #1

Merged
vx-clutch merged 20 commits from rewrite into main 2026-01-14 20:39:15 -05:00
7 changed files with 24 additions and 280 deletions
Showing only changes of commit 3c36fc3963 - Show all commits

View File

@@ -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

View File

@@ -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 <language> set project type
-S small project creation
-f overwrite existing files
-n <name> set project name
-a <author> 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

View File

@@ -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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#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

View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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]... <version> <dir>
{{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