feat: simple
This commit is contained in:
@@ -45,7 +45,5 @@ typedef struct {
|
|||||||
} manifest_t;
|
} manifest_t;
|
||||||
|
|
||||||
int create_project(manifest_t manifest);
|
int create_project(manifest_t manifest);
|
||||||
int mkdir_p(const char *path);
|
|
||||||
int cfprintf(const char *path, const char *format, ...);
|
|
||||||
|
|
||||||
#endif // YAIT_H
|
#endif // YAIT_H
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../include/yait.h"
|
#include "../include/yait.h"
|
||||||
|
#include "util.h"
|
||||||
#include "contents.h"
|
#include "contents.h"
|
||||||
|
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
@@ -20,14 +21,20 @@ int create_project(manifest_t manifest)
|
|||||||
chdir(manifest.project);
|
chdir(manifest.project);
|
||||||
|
|
||||||
if (manifest.flags.simple) {
|
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(
|
cfprintf(
|
||||||
"Makefile",
|
"Makefile",
|
||||||
".POSIX:\nCC ::= gcc\nCFLAGS ::= -Wall --std=c23 -Wpedantic\n\nall: %s",
|
".POSIX:\nCC ::= gcc\nCFLAGS ::= -Wall --std=c23 -Wpedantic\n\nall: %s",
|
||||||
manifest.project);
|
manifest.project);
|
||||||
|
fprintf(stderr, "Created files 1\r");
|
||||||
cfprintf("README", "%s", manifest.project);
|
cfprintf("README", "%s", manifest.project);
|
||||||
|
fprintf(stderr, "Created files 2\r");
|
||||||
|
|
||||||
snprintf(buffer, BUFSIZ, "%s.c", manifest.project);
|
snprintf(buffer, BUFSIZ, "%s.c", manifest.project);
|
||||||
cfprintf(buffer, "");
|
cfprintf(buffer, "");
|
||||||
|
fputs("Created files 3, done.\n", stderr);
|
||||||
|
/* We exit early because the simple flag is an overridding flag. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@@ -135,5 +136,9 @@ int main(int argc, char **argv)
|
|||||||
get_name(&manifest.name);
|
get_name(&manifest.name);
|
||||||
status = create_project(manifest);
|
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;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/util.h
10
src/util.h
@@ -5,14 +5,10 @@
|
|||||||
|
|
||||||
licence_t TOlicence(const char *s);
|
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,
|
int getopt_long(int argc, char *const argv[], const char *optstring,
|
||||||
const struct option *longopts, int *longindex);
|
const struct option *longopts, int *longindex);
|
||||||
|
|
||||||
|
int mkdir_p(const char *path);
|
||||||
|
int cfprintf(const char *path, const char *format, ...);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Usage ./format
|
# Usage ./format
|
||||||
|
|
||||||
find . -name "*.c" -exec clang-format -i {} \;
|
find . -name "*.c" -exec clang-format -i --verbose {} \;
|
||||||
find . -name "*.h" -exec clang-format -i {} \;
|
find . -name "*.h" -exec clang-format -i --verbose {} \;
|
||||||
|
|||||||
Reference in New Issue
Block a user