From fbbcb22867c57f99b89b6318f0d63f353612db6c Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Fri, 22 Aug 2025 08:45:36 -0400 Subject: [PATCH] feat: simple --- include/yait.h | 2 -- src/create_project.c | 7 +++++++ src/main.c | 5 +++++ src/util.h | 10 +++------- tools/format | 6 +++--- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/yait.h b/include/yait.h index 9713199..33a3805 100644 --- a/include/yait.h +++ b/include/yait.h @@ -45,7 +45,5 @@ typedef struct { } manifest_t; int create_project(manifest_t manifest); -int mkdir_p(const char *path); -int cfprintf(const char *path, const char *format, ...); #endif // YAIT_H diff --git a/src/create_project.c b/src/create_project.c index ced71b7..5ae6a57 100644 --- a/src/create_project.c +++ b/src/create_project.c @@ -10,6 +10,7 @@ #include #include "../include/yait.h" +#include "util.h" #include "contents.h" char buffer[BUFSIZ]; @@ -20,14 +21,20 @@ int create_project(manifest_t manifest) chdir(manifest.project); if (manifest.flags.simple) { + /* This only works if the source + files's root name is the same as the target on all of the Makefile becuase of how it checks for files. */ cfprintf( "Makefile", ".POSIX:\nCC ::= gcc\nCFLAGS ::= -Wall --std=c23 -Wpedantic\n\nall: %s", manifest.project); + fprintf(stderr, "Created files 1\r"); cfprintf("README", "%s", manifest.project); + fprintf(stderr, "Created files 2\r"); snprintf(buffer, BUFSIZ, "%s.c", manifest.project); cfprintf(buffer, ""); + fputs("Created files 3, done.\n", stderr); + /* We exit early because the simple flag is an overridding flag. */ return 0; } diff --git a/src/main.c b/src/main.c index 1e557b3..5471f6c 100644 --- a/src/main.c +++ b/src/main.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -135,5 +136,9 @@ int main(int argc, char **argv) get_name(&manifest.name); status = create_project(manifest); + char buffer[PATH_MAX]; + getcwd(buffer, PATH_MAX); + fprintf(stderr, "Created %s at\n %s\n", manifest.project, buffer); + return EXIT_SUCCESS; } diff --git a/src/util.h b/src/util.h index 1fbe065..7058289 100644 --- a/src/util.h +++ b/src/util.h @@ -5,14 +5,10 @@ licence_t TOlicence(const char *s); -struct option { - const char *name; - int has_arg; - int *flag; - int val; -}; - int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex); +int mkdir_p(const char *path); +int cfprintf(const char *path, const char *format, ...); + #endif diff --git a/tools/format b/tools/format index 34a70fc..43a85ff 100755 --- a/tools/format +++ b/tools/format @@ -1,6 +1,6 @@ -#!/usr/sh +#!/bin/sh # Usage ./format -find . -name "*.c" -exec clang-format -i {} \; -find . -name "*.h" -exec clang-format -i {} \; +find . -name "*.c" -exec clang-format -i --verbose {} \; +find . -name "*.h" -exec clang-format -i --verbose {} \;