You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.1 KiB

/*
behold! my garbage code. (and other people's better code but whatever)
*/
#include <cstdlib>
#include <iostream>
#include <sys/ioctl.h>
#include <string.h>
#include <json/json.h>
#include "oof.h"
#define OOF_IMPL
#ifdef __linux__
const char* defaultPath = "$HOME/.config/factorioclone";
#endif
#ifdef __WIN32__
#include <windows.h>
const char* defaultPath = getenv("APPDATA");
#endif
const char* filename = "main";
int c;
int main(int argc, char **argv)
{
bool debug = false, help = false;
char* fileToParse = "";
struct winsize w;
ioctl(0, TIOCGWINSZ, &w);
std::cout << w.ws_row << " lines\n";
std::cout << w.ws_col << " columns\n";
while (--argc > 0 && (*++argv)[0] == '-') {
while (c = *++argv[0]) {
switch(c) {
case 'd':
debug = 1;
break;
case 'h':
help = 1;
break;
}
}
}
std::cout << "debug: " << debug << " help: " << help << std::endl;
if (help) {
std::cout << "this is a factorio clone. we don't have a working name for it yet, but dragon lord suggested \"beurocra-tech\"" << std::endl;
std::cout << "usage: " << filename << " -dh <*.json>" << std::endl;
return 0;
}
if (debug) {
std::cout << "filename: " << filename << " default path: " << defaultPath << std::endl;
}
bool ohNo = false;
for (int i = 0; i < argc; i++) {
char* arg = argv[i];
char* arg_kept = arg;
int filename_length = 0;
for (int char_count = 0; char_count < 500; char_count++) { // how to not check file types; note to self, make this work with magic numbers and not file extensions
if (arg[char_count] == '\0') { filename_length = char_count; printf("it worked up to here"); break;}
}
for (int j = 0; j < filename_length-7; j++) { // why am i allowed near a computer
arg++;
}
if (!strcmp(arg, ".json")) {
printf("oh god it worked");
printf("%s", arg_kept);
ohNo = true;
}
if (ohNo) {fileToParse = arg_kept;}
}
// Json::CharReaderBuilder jsonParser;
// jsonParser["collectComments"] = false;
// Json::Value parsedJson;
// std::string oops;
// bool read = Json::parseFromStream(jsonParser, std::cin, &parsedJson, &oops);
// if (!read) {printf("oops! errors: "); std::cout << oops;}
return 0;
}