From: David ‘Bombe’ Roden Date: Sat, 5 Jul 2008 12:47:46 +0000 (+0200) Subject: syntax help and some cmd-line parsing X-Git-Tag: 0.1~52 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=39c7e66703f6ec99a592d065546e6cc119a8c930;p=ecparse.git syntax help and some cmd-line parsing --- diff --git a/Main.cpp b/Main.cpp index aa44bdc..364d62b 100644 --- a/Main.cpp +++ b/Main.cpp @@ -2,11 +2,34 @@ * © 2008 by David Roden */ +#include #include "Main.h" +void printSyntaxHelp() { + printf("ecparse %s - © 2008 by David ‘Bombe’ Roden ]\n"); +} + int main(int argc, char** argv) { FileReaderInput* fileReaderInput; CollectionReader* collectionReader; + char* currentArgument; + char* fileToOpen = NULL; + int argumentIndex; + + for (argumentIndex = 1; argumentIndex < argc; argumentIndex++) { + currentArgument = argv[argumentIndex]; + if (!strcmp("--help", currentArgument) || !strcmp("-h", currentArgument)) { + printSyntaxHelp(); + } else if (!strcmp("--verbose", currentArgument) || !strcmp("-v", currentArgument)) { + GlobalSettings::getInstance()->setVerbose(true); + } else if (!strcmp("--file", currentArgument) || !strcmp("-f", currentArgument)) { + fileToOpen = currentArgument; + } else { + printf("Unknown Parameter: %s\n", currentArgument); + return 1; + } + } return 0; }