diff --git a/src/zimwriterfs/zimwriterfs.cpp b/src/zimwriterfs/zimwriterfs.cpp index c7f71d7c..939d1d5a 100644 --- a/src/zimwriterfs/zimwriterfs.cpp +++ b/src/zimwriterfs/zimwriterfs.cpp @@ -82,10 +82,27 @@ bool thereAreMissingArguments() } bool checkDescriptionLengths() { + if (description.empty()) { + std::cerr << "Description metadata should not be empty." << std::endl; + return false; + } + if (!longDescription.empty() && longDescription.length() < description.length()) { - return true; + std::cerr << "Long description should not be shorter than the short description." << std::endl; + return false; + } + + if (description.length() > 80) { + std::cerr << "Description length exceeds the 80 character limit." << std::endl; + return false; } - return false; + + if (!longDescription.empty() && longDescription.length() > 4000) { + std::cerr << "Long description length exceeds the 4000 character limit." << std::endl; + return false; + } + + return true; } // Global flags @@ -308,22 +325,12 @@ void parse_args(int argc, char** argv) } } } while (c != -1); - - if(checkDescriptionLengths()){ - std::cerr << "Long description should not be shorter than the short description." << std::endl; - exit(1); - } - - if (description.length() > 80) { - std::cerr << "Description length exceeds the 80 character limit." << std::endl; - exit(1); - } - if (!longDescription.empty() && longDescription.length() > 4000) { - std::cerr << "Long description length exceeds the 4000 character limit." << std::endl; + if ( !checkDescriptionLengths() ) { exit(1); } + while (optind < argc) { if (directoryPath.empty()) { directoryPath = argv[optind++];