From efe280f988beaef9a525644e5b746d36eeaa1bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bend=C3=ADk?= Date: Wed, 22 Aug 2012 15:49:45 +0200 Subject: [PATCH] Added commandline parameters. --- mapper.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/mapper.cpp b/mapper.cpp index f5a66f2..38c0e94 100644 --- a/mapper.cpp +++ b/mapper.cpp @@ -7,7 +7,57 @@ * ===================================================================== */ +#include +#include +#include + +using namespace std; + +void usage() +{ + const char *usage_text = "minetestmapper.py [options]\n\ + -i/--input \n\ + -o/--output \n\ + --bgcolor \n\ + --scalecolor \n\ + --playercolor \n\ + --origincolor \n\ + --drawscale\n\ + --drawplayers\n\ + --draworigin\n\ + --drawunderground\n\ +Color format: '#000000'\n"; + std::cout << usage_text; +} + int main(int argc, char *argv[]) { - return 0; + static struct option long_options[] = + { + {"help", no_argument, 0, 'h'}, + {"input", required_argument, 0, 'i'}, + {"output", required_argument, 0, 'o'}, + {"bgcolor", required_argument, 0, 'b'}, + {"scalecolor", required_argument, 0, 's'}, + {"origincolor", required_argument, 0, 'r'}, + {"playercolor", required_argument, 0, 'p'}, + {"draworigin", no_argument, 0, 'w'}, + {"drawplayers", no_argument, 0, 'l'}, + {"drawscale", no_argument, 0, 'c'}, + {"drawunderground", no_argument, 0, 'u'} + }; + int option_index = 0; + int c = getopt_long(argc, argv, "hi:o:", long_options, &option_index); + if (c == -1) { + usage(); + exit(-1); + } + std::cout << c << std::endl; + while (1) { + c = getopt_long(argc, argv, "hi:o:", long_options, &option_index); + if (c == -1) { + break; + } + std::cout << c << std::endl; + } }