wip
This commit is contained in:
6
Makefile
6
Makefile
@@ -15,6 +15,7 @@ export E Q
|
||||
PROGRAM = yait
|
||||
SRC = $(wildcard *.c)
|
||||
OBJ = $(SRC:.c=.o)
|
||||
HDR = $(wildcard *.h)
|
||||
|
||||
CC = gcc
|
||||
WARNINGS = -Wall -Wstrict-prototypes
|
||||
@@ -25,7 +26,7 @@ LDFLAGS =
|
||||
BINDIR = /usr/bin
|
||||
LIBDIR = /usr/lib
|
||||
|
||||
$(PROGRAM): $(OBJ)
|
||||
$(PROGRAM): $(OBJ) $(HDR)
|
||||
$(E) " LINK " $@
|
||||
$(Q) $(CC) $(LDFLAGS) $(DEFINES) -o $@ $(OBJ) $(LIBS)
|
||||
|
||||
@@ -33,6 +34,9 @@ clean:
|
||||
$(E) " CLEAN"
|
||||
$(Q) rm -f $(PROGRAM) $(OBJ)
|
||||
|
||||
install: $(PROGRAM)
|
||||
cp $(PROGRAM) ${BINDIR}
|
||||
|
||||
.c.o:
|
||||
$(E) " CC " $@
|
||||
$(Q) $(CC) $(CFLAGS) $(DEFINES) -c $< -o $@
|
||||
|
||||
8
README
8
README
@@ -34,11 +34,9 @@ Something is gone:
|
||||
|
||||
o None
|
||||
|
||||
HOW TO INSTALL yait/fSD?
|
||||
|
||||
HOW TO BUILD yait/fSD?
|
||||
|
||||
o UNIX: Compile the packge with make and install manually with for your
|
||||
given system.
|
||||
o UNIX: Look at estruct.h, do a 'make', test the program, 'make install'.
|
||||
|
||||
|
||||
ACKNOWLEDGEMENTS AND STATUS
|
||||
@@ -47,3 +45,5 @@ 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 10, 2025
|
||||
|
||||
76
full.c
Normal file
76
full.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/* 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
Normal file
6
full.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef FULL_H_
|
||||
#define FULL_H_
|
||||
|
||||
int full_project_init_and_cd(char *src);
|
||||
|
||||
#endif /* FULL_H_ */
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef GLOBALS_H_
|
||||
#define GLOBALS_H_
|
||||
|
||||
enum { SINGLE, FULL };
|
||||
|
||||
#define NPAT 4096 /* number of bytes for path buffer */
|
||||
|
||||
#endif /* GLOBALS_H_ */
|
||||
|
||||
65
main.c
65
main.c
@@ -18,16 +18,18 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "proj.h"
|
||||
#include "shell.h"
|
||||
#include "usage.h"
|
||||
#include "version.h"
|
||||
#include "proj.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\n", stdout);
|
||||
fputs(" -S enable shell creation mode as a full project\n", stdout);
|
||||
fputs(" --help display this help and exit\n", stdout);
|
||||
fputs(" --version output version information and exit\n", stdout);
|
||||
|
||||
@@ -36,37 +38,44 @@ void usage(int status)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int c = 0;
|
||||
int S = 0;
|
||||
int carg;
|
||||
int mode = -1;
|
||||
char *package = NULL;
|
||||
|
||||
if (argc == 2) {
|
||||
if (strcmp(argv[1], "--help") == 0) {
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
if (strcmp(argv[1], "--version") == 0) {
|
||||
version();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
for (carg = 0; carg < argc; ++carg) {
|
||||
if (argv[carg][0] == '-') {
|
||||
switch (argv[carg][1]) {
|
||||
case 'S':
|
||||
S = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argc < 2 || c)
|
||||
if (argc < 2)
|
||||
die("not enough arguments");
|
||||
|
||||
char *package = argv[carg - 1];
|
||||
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) {
|
||||
S = 1;
|
||||
mode = SINGLE;
|
||||
}
|
||||
else if (strcmp(argv[i], "-S") == 0) {
|
||||
S = 1;
|
||||
mode = FULL;
|
||||
}
|
||||
else
|
||||
die("unknown option");
|
||||
}
|
||||
else
|
||||
package = argv[i];
|
||||
}
|
||||
|
||||
if (S)
|
||||
makeshell(package);
|
||||
if (!package)
|
||||
die("no package name provided");
|
||||
|
||||
if (S == SINGLE || S == FULL)
|
||||
makeshell(package, mode);
|
||||
else
|
||||
makeproj(package);
|
||||
|
||||
|
||||
22
shell.c
22
shell.c
@@ -11,18 +11,25 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
if (ffexist(src))
|
||||
die("%s already exists", src);
|
||||
|
||||
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");
|
||||
license = getstring("License");
|
||||
char *description = getstring("Description");
|
||||
|
||||
ffwrite(src, "\
|
||||
@@ -58,7 +65,8 @@ while [ $# -gt 0 ]; do\n\
|
||||
exit 1 ;;\n\
|
||||
esac\n\
|
||||
shift\n\
|
||||
done", license, description, 2025, "fSD", description);
|
||||
done",
|
||||
license, description, 2025, "fSD", description);
|
||||
|
||||
struct stat st;
|
||||
if (stat(src, &st) == 0)
|
||||
|
||||
2
shell.h
2
shell.h
@@ -1,6 +1,6 @@
|
||||
#ifndef SHELL_H_
|
||||
#define SHELL_H_
|
||||
|
||||
int makeshell(char *src);
|
||||
int makeshell(char *src, int complexity);
|
||||
|
||||
#endif /* SHELL_H_ */
|
||||
|
||||
20
single.c
Normal file
20
single.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* 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;
|
||||
}
|
||||
Reference in New Issue
Block a user