From 39c7e66703f6ec99a592d065546e6cc119a8c930 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 5 Jul 2008 14:47:46 +0200 Subject: [PATCH] syntax help and some cmd-line parsing --- Main.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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; } -- 2.7.4