// Kyler Olsen
// YREA SLS
// Main File
// October 2025

#include <stdio.h>
#include <stddef.h>
#include <string.h>

#include "sls/meta.h"
#include "sls/bool.h"
#include "sls/string.h"
#include "sls/repl.h"
#include "sls/file.h"

int main(int argc, char *argv[]) {
    Boolean version = FALSE;
    char *filename = NULL;

    if (argc == 2) {
        if (strcmp(argv[1], "--version") == 0) version = TRUE;
        else if (strcmp(argv[1], "-v") == 0) version = TRUE;
        else filename = argv[1];
    } else if (argc > 2) {
        printf("To many arguments!");
        return 1;
    }

    if (version) {
        print_version();
        return 0;
    } else if (filename != NULL) {
        SlsStr sls_filename = sls_str_malloc(filename, strlen(filename));
        int rv = file(sls_filename);
        sls_str_free(&sls_filename);
        return rv;
    } else {
        return repl();
    }
}
