the c book has a lot of good ways to write this stuff

master
ieee 802.11ac 2 years ago
parent d2c73ba62d
commit 01c0e49de4

@ -12,44 +12,30 @@ const char* defaultPath = "$HOME/.config/factorioclone";
#endif
#ifdef __WIN32__
#include <windows.h>
char* defaultPath = getenv("APPDATA");
const char* defaultPath = getenv("APPDATA");
#endif
const char* filename = "main";
int main(int argc, char **argv)
{
struct winsize w;
ioctl(0, TIOCGWINSZ, &w);
std::cout << w.ws_row << " lines\n";
std::cout << w.ws_col << " columns\n";
if (argc==1) {
std::cout << "no arguments :(" << std::endl;
} else {
std::cout << argc-1 << " arguments" << std::endl;
for (int i = 1; i < argc; i++) {
char* arg = argv[i];
std::string argMidstep = arg;
std::vector<char> argBrokenDown(argMidstep.begin(), argMidstep.end());
bool argMultiOption = false;
if (!strcmp(&argBrokenDown[0], "-")) {
argMultiOption = true;
}
if (!strcmp(arg, "--help")) {
std::cout << "this is a factorio clone that runs in the terminal. it is shit. shoutouts to dragon lord for thinking up the name \"beaurocra-tech\"" << std::endl;
std::cout << "syntax: " << filename << " [arguments] <*.json>" << std::endl; // why json? because 1. it's convenient and 2. i'm too lazy to make a blotterv5 parser
break;
} else if (argMultiOption) {
for (int i = 0; i < sizeof(argBrokenDown); i++) {
if (!strcmp(arg, "--debug") | !strcmp(&argBrokenDown[i], "d")) {
std::cout << "default path: " << defaultPath << std::endl;
}
}
}
}
}
return 0;
int c;
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;
}
}
}
return 0;
}

Loading…
Cancel
Save