Started working on argv parsing
This commit is contained in:
parent
46a855abd0
commit
dc6be59fab
|
|
@ -5,6 +5,9 @@ CFLAGS ?= -std=c99 -Wall -Wextra -Werror -g -Iinclude -MMD -MP
|
|||
LDFLAGS ?=
|
||||
CTESTFLAGS ?= -std=c99 -Wall -Wextra -Wno-unused-function -Werror -g -O0 -Iinclude -MMD -MP
|
||||
|
||||
GIT_COMMIT := $(shell git describe --always --dirty --abbrev=7)
|
||||
CFLAGS += -DGIT_COMMIT_HASH="\"$(GIT_COMMIT)\""
|
||||
|
||||
SRCDIR := src
|
||||
OBJDIR := obj
|
||||
BINDIR := bin
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
// Kyler Olsen
|
||||
// YREA SLS
|
||||
// Main Header
|
||||
// November 2025
|
||||
|
||||
#ifndef SLS_MAIN_H
|
||||
#define SLS_MAIN_H
|
||||
|
||||
#define SLS_NAME "SLS_C"
|
||||
#define SLS_VER "a.0.0"
|
||||
|
||||
#ifndef GIT_COMMIT_HASH
|
||||
#define GIT_COMMIT_HASH "UNKNOWN"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define COMPILER_NAME "GCC"
|
||||
#define COMPILER_VER __GNUC__
|
||||
|
||||
#elif defined(__clang__)
|
||||
#define COMPILER_NAME "Clang"
|
||||
#define COMPILER_VER __clang_major__
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
#define COMPILER_NAME "MSVC"
|
||||
#define COMPILER_VER _MSC_VER
|
||||
|
||||
#else
|
||||
#define COMPILER_NAME "Unknown compiler"
|
||||
#define COMPILER_VER 0
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SLS_MAIN_H
|
||||
|
|
@ -4,8 +4,33 @@
|
|||
// October 2025
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sls/main.h"
|
||||
#include "sls/bool.h"
|
||||
#include "sls/repl.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
printf("Hello, world!\n");
|
||||
Boolean version = FALSE;
|
||||
Boolean file = FALSE;
|
||||
char *filename = NULL;
|
||||
|
||||
(void)file;
|
||||
(void)filename;
|
||||
|
||||
for (int i = 0; i < argc; i++) {
|
||||
if (strcmp(argv[i], "--version") == 0) version = TRUE;
|
||||
if (strcmp(argv[i], "-v") == 0) version = TRUE;
|
||||
}
|
||||
|
||||
if (version) {
|
||||
printf("YREA SLS (" SLS_NAME ") " SLS_VER " (" GIT_COMMIT_HASH ")\n");
|
||||
printf("Compiled with " COMPILER_NAME " %d at " __DATE__ " " __TIME__ "\n", COMPILER_VER);
|
||||
return 0;
|
||||
} else if (file) {
|
||||
return 1;
|
||||
} else {
|
||||
return repl(0, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,3 +4,10 @@
|
|||
// November 2025
|
||||
|
||||
#include "sls/repl.h"
|
||||
|
||||
int repl(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue