Skip to content

Commit

Permalink
added a check on description being non-empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Onyx2406 authored Mar 21, 2023
1 parent c922868 commit efce1e8
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions src/zimwriterfs/zimwriterfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++];
Expand Down

0 comments on commit efce1e8

Please sign in to comment.