diff --git a/TileGenerator.cpp b/TileGenerator.cpp index 7870016..e75adc3 100644 --- a/TileGenerator.cpp +++ b/TileGenerator.cpp @@ -311,6 +311,22 @@ void TileGenerator::parseColorsStream(std::istream &in) } } +std::set TileGenerator::getSupportedBackends() +{ + std::set r; + r.insert("sqlite3"); +#if USE_POSTGRESQL + r.insert("postgresql"); +#endif +#if USE_LEVELDB + r.insert("leveldb"); +#endif +#if USE_REDIS + r.insert("redis"); +#endif + return r; +} + void TileGenerator::openDb(const std::string &input) { std::string backend = m_backend; diff --git a/include/TileGenerator.h b/include/TileGenerator.h index 4149b50..50250f1 100644 --- a/include/TileGenerator.h +++ b/include/TileGenerator.h @@ -85,12 +85,14 @@ public: void setExhaustiveSearch(int mode); void parseColorsFile(const std::string &fileName); void setBackend(std::string backend); - void generate(const std::string &input, const std::string &output); - void printGeometry(const std::string &input); void setZoom(int zoom); void setScales(uint flags); void setDontWriteEmpty(bool f); + void generate(const std::string &input, const std::string &output); + void printGeometry(const std::string &input); + static std::set getSupportedBackends(); + private: void parseColorsStream(std::istream &in); void openDb(const std::string &input); diff --git a/mapper.cpp b/mapper.cpp index 791e469..42d337c 100644 --- a/mapper.cpp +++ b/mapper.cpp @@ -1,9 +1,10 @@ +#include #include #include #include #include #include -#include +#include #include #include #include @@ -12,30 +13,47 @@ static void usage() { - const char *usage_text = "minetestmapper [options]\n" - " -i/--input \n" - " -o/--output \n" - " --bgcolor \n" - " --scalecolor \n" - " --playercolor \n" - " --origincolor \n" - " --drawscale\n" - " --drawplayers\n" - " --draworigin\n" - " --drawalpha\n" - " --noshading\n" - " --noemptyimage\n" - " --min-y \n" - " --max-y \n" - " --backend \n" - " --geometry x:y+w+h\n" - " --extent\n" - " --zoom \n" - " --colors \n" - " --scales [t][b][l][r]\n" - " --exhaustive never|y|full|auto\n" - "Color format: '#000000'\n"; - std::cout << usage_text; + const std::pair options[] = { + {"-i/--input", ""}, + {"-o/--output", ""}, + {"--bgcolor", ""}, + {"--scalecolor", ""}, + {"--playercolor", ""}, + {"--origincolor", ""}, + {"--drawscale", ""}, + {"--drawplayers", ""}, + {"--draworigin", ""}, + {"--drawalpha", ""}, + {"--noshading", ""}, + {"--noemptyimage", ""}, + {"--min-y", ""}, + {"--max-y", ""}, + {"--backend", ""}, + {"--geometry", "x:y+w+h"}, + {"--extent", ""}, + {"--zoom", ""}, + {"--colors", ""}, + {"--scales", "[t][b][l][r]"}, + {"--exhaustive", "never|y|full|auto"}, + }; + const char *top_text = + "minetestmapper -i -o [options]\n" + "Generate an overview image of a Minetest map.\n" + "\n" + "Options:\n"; + const char *bottom_text = + "\n" + "Color format: hexadecimal '#RRGGBB', e.g. '#FF0000' = red\n"; + + printf("%s", top_text); + for (const auto &p : options) + printf(" %-18s%s\n", p.first, p.second); + printf("%s", bottom_text); + auto backends = TileGenerator::getSupportedBackends(); + printf("Supported backends: "); + for (auto s : backends) + printf("%s ", s.c_str()); + printf("\n"); } static bool file_exists(const std::string &path)