From d59fb39857aba67014c02bd00f6170101a8fab8e Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Thu, 21 Mar 2024 04:38:23 +1100 Subject: [PATCH] cut a versioned release before making potentially breaking changes --- CMakeLists.txt | 4 ++-- README.md | 1 + src/tmx2gba.cpp | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d47d3f0..c682586 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.1 FATAL_ERROR) -project(tmx2gba) +cmake_minimum_required(VERSION "3.5" FATAL_ERROR) +project(tmx2gba VERSION "0.3") # Options option(TMX2GBA_DKP_INSTALL "Install into DEVKITPRO prefix" OFF) diff --git a/README.md b/README.md index e7c52ac..983e3e6 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ tmx2gba [-h] [-r offset] [-lyc name] [-p 0-15] <-i inpath> <-o outpath> | Command | Required | Notes | |--------------|----------|-----------------------------------------------------------------------| | -h | N/A | Display help & command info. | +| -v | No | Display version & quit. | | -l (name) | No | Name of layer to use (default first layer in TMX). | | -y (name) | No | Layer for palette mappings. | | -c (name) | No | Output a separate 8bit collision map of the specified layer. | diff --git a/src/tmx2gba.cpp b/src/tmx2gba.cpp index 0e76d28..130ea6a 100644 --- a/src/tmx2gba.cpp +++ b/src/tmx2gba.cpp @@ -15,8 +15,10 @@ const std::string helpUsage = "Usage: tmx2gba [-h] [-f file] [-r offset] [-lyc name] [-p 0-15] [-m name;id] <-i inpath> <-o outpath>"; const std::string helpShort = "Run 'tmx2gba -h' to view all available options."; +const std::string versionStr = "tmx2gba version 0.3, (c) 2015-2022 a dinosaur"; const std::string helpFull = R"( -h ------------ Display this help & command info. +-v ------------ Display version & quit. -l ----- Name of layer to use (default first layer in TMX). -y ----- Layer for palette mappings. -c ----- Output a separate 8bit collision map of the specified layer. @@ -29,7 +31,7 @@ const std::string helpFull = R"( struct Arguments { - bool help = false; + bool help = false, showVersion = false; std::string inPath, outPath; std::string layer, collisionlay, paletteLay; std::string flagFile; @@ -43,13 +45,16 @@ void ParseArgs(int argc, char** argv, Arguments& p) { int opt; optreset = 1; - while ((opt = getopt(argc, argv, "hr:l:c:p:y:m:i:o:f:")) > 0) + while ((opt = getopt(argc, argv, "hvr:l:c:p:y:m:i:o:f:")) > 0) { switch (opt) { case ('h'): p.help = true; return; + case ('v'): + p.showVersion = true; + return; case ('l'): p.layer = optarg; break; case ('c'): p.collisionlay = optarg; break; @@ -146,6 +151,11 @@ int main(int argc, char** argv) std::cout << helpUsage << std::endl << helpFull << std::endl; return 0; } + if (p.showVersion) + { + std::cout << versionStr << std::endl; + return 0; + } if (!p.flagFile.empty()) { @@ -155,7 +165,7 @@ int main(int argc, char** argv) std::cerr << "Failed to open param file." << std::endl; return -1; } - + std::vector fileArgTokens; fileArgTokens.push_back("auu~~"); bool carry = false;