This commit is contained in:
2025-08-21 18:58:27 -04:00
parent 592301d1f8
commit a59730f4d4
6 changed files with 37 additions and 17 deletions

1
TODO
View File

@@ -3,5 +3,6 @@ VX yait --- TODO
Todo: Todo:
* Argument Parsing * Argument Parsing
* Project creation
end of file TODO end of file TODO

BIN
bin/yait

Binary file not shown.

View File

@@ -1,4 +1,4 @@
PREFIX=/usr/bin/ PREFIX=/usr/bin/
CFLAGS=-ggdb -std=c23 CFLAGS=-Wall -Wextra -O2 --std=c23 -Wpedantic
LDFLAGS= LDFLAGS=
CC=gcc CC=gcc

View File

@@ -8,9 +8,9 @@
// Usage: yait [OPTION]... <PROJECT> // Usage: yait [OPTION]... <PROJECT>
#define _POSIX_C_SOURCE 200809L // popen extention
#include <getopt.h> #include <getopt.h>
#include <pwd.h> #include <pwd.h>
#define _POSIX_C_SOURCE 200809L // popen extention
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -21,35 +21,33 @@
#include "util.h" #include "util.h"
#define print_option(option, description) \ #define print_option(option, description) \
fprintf(stderr, " %-20s %-20s\n", option, description) printf(" %-20s %-20s\n", option, description)
static void usage(int status) static void usage(int status)
{ {
if (status != 0) { if (status != 0) {
fputs("Try 'yait --help' for more information.\n", stderr); puts("Try 'yait --help' for more information.\n");
return; return;
} }
fputs("Usage: yait [OPTION]... <PATH>", stderr); puts("Usage: yait [OPTION]... <PATH>");
fputs("Creates a C project with opinionated defaults.", stderr); puts("Creates a C project with opinionated defaults");
fputs("When only given the first argument it will detect your name.\n", puts("When only given the first argument it will detect your name\n");
stderr); puts("Mandatory arguments to long options are mandatory for short options too");
fputs("Mandatory arguments to long options are mandatory for short options too",
stderr);
print_option("--posix", "Enable POSIX compliance"); print_option("--posix", "Enable POSIX compliance");
print_option("--git", "Do not inititize git reposity"); print_option("--git", "Do not inititize git reposity");
print_option("--clang", "Add clang-format files and tooling"); print_option("--clang", "Add clang-format files and tooling");
print_option("-L <licence>", "Set licence"); print_option("-L <licence>", "Set licence");
print_option("-l <library>", "Add a library"); print_option("-l <library>", "Add a library");
print_option("-C", "Use C++"); print_option("-C", "Use C++");
print_option("--GNU", print_option("--GNU", "Add version and help parsing");
"Add GNU argument parsing: --version, and --help");
print_option("-S, --simple", "Enable simple mode"); print_option("-S, --simple", "Enable simple mode");
fputs(" --help display this help text and exit", stderr); puts(" --help display this help text and exit\n");
fputs(" --version output version information and exit", stderr); puts(" --version output version information and exit\n");
} }
static int parse_arguments(manifest_t *conf, int argc, char **argv) [[maybe_unused]] static int parse_arguments(manifest_t *conf, int argc,
char **argv)
{ {
int opt; int opt;
@@ -131,7 +129,8 @@ int main(int argc, char **argv)
return fprintf(stderr, "error: %s\n", strerror(status)), return fprintf(stderr, "error: %s\n", strerror(status)),
EXIT_FAILURE; EXIT_FAILURE;
parse_arguments(&manifest, argc, argv); // parse_arguments(&manifest, argc, argv);
manifest.flags.simple = true;
get_name(&manifest.name); get_name(&manifest.name);
status = create_project(manifest); status = create_project(manifest);

20
tools/Cleanup Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/sh
# Usage: ./Cleanup
fatal() {
echo "$@"
echo fail.
exit 1
}
if [ ! -d "./tools" ]; then
echo "error: must be run from parent directory"
exit 1
fi
sh ./tools/format || fatal Could not run './tools/format'
rm -rf .cache || fatal Could not run 'rm -rf .cache'
make dist-clean || fatal Could not run 'make dist-clean'
echo done.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/sh
# Usage ./format # Usage ./format