From 0e754cf2f00971ffcd1461c35568dd3f698bf848 Mon Sep 17 00:00:00 2001 From: Patrick Brosi Date: Mon, 2 Dec 2024 15:13:44 +0100 Subject: [PATCH] fix a typo in the help text for --output-compression, dont allow unknown compression method arguments for that options --- include/osm2rdf/config/Constants.h | 2 +- src/config/Config.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/osm2rdf/config/Constants.h b/include/osm2rdf/config/Constants.h index c7124668..8d341a15 100644 --- a/include/osm2rdf/config/Constants.h +++ b/include/osm2rdf/config/Constants.h @@ -80,7 +80,7 @@ const static inline std::string OUTPUT_COMPRESS_OPTION_SHORT = ""; const static inline std::string OUTPUT_COMPRESS_OPTION_LONG = "output-compression"; const static inline std::string OUTPUT_COMPRESS_OPTION_HELP = - "Output file compression, valid values: none, bz2, gz2"; + "Output file compression, valid values: none, bz2, gz"; const static inline std::string STORE_LOCATIONS_INFO = "Storing locations osmium locations:"; diff --git a/src/config/Config.cpp b/src/config/Config.cpp index 4f1e8a52..4a9d036c 100644 --- a/src/config/Config.cpp +++ b/src/config/Config.cpp @@ -507,9 +507,19 @@ void osm2rdf::config::Config::fromArgs(int argc, char** argv) { // Output output = outputOp->value(); outputFormat = outputFormatOp->value(); - outputCompress = outputCompressOp->value() == "none" - ? NONE - : (outputCompressOp->value() == "gz" ? GZ : BZ2); + if (outputCompressOp->value() == "none") { + outputCompress = NONE; + } else if (outputCompressOp->value() == "gz") { + outputCompress = GZ; + } else if (outputCompressOp->value() == "bz2") { + outputCompress = BZ2; + } else { + throw popl::invalid_option( + outputCompressOp.get(), + popl::invalid_option::Error::invalid_argument, + popl::OptionName::long_name, outputCompressOp->value(), ""); + } + outputKeepFiles = outputKeepFilesOp->is_set(); if (output.empty()) { outputCompress = NONE;