Skip to content

Commit

Permalink
Add option -e, --exit-ignore-warnings
Browse files Browse the repository at this point in the history
Return with exit code 0 even if there are warnings. Makes use in scripts
simpler.
  • Loading branch information
joto committed Jun 20, 2024
1 parent 0c2fca9 commit d0ecd1e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion man/osmcoastline.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ description of the options below and the README.md for details.
-d, \--debug
: Enable debugging output.

-e, \--exit-ignore-warnings
: Return with exit code 0 even if there are warnings.

-f, \--overwrite
: Overwrite output file if it already exists.

Expand Down Expand Up @@ -114,7 +117,7 @@ program first. See its man page for details.
~ if everything was okay

1
~ if there were warnings while processing the coastline
~ if there were warnings while processing the coastline (unless -e is set)

2
~ if there were errors while processing the coastline
Expand Down
7 changes: 6 additions & 1 deletion src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static void print_help() {
<< " -b, --bbox-overlap=OVERLAP - Set overlap when splitting polygons\n"
<< " -i, --no-index - Do not create spatial indexes in output db\n"
<< " -d, --debug - Enable debugging output\n"
<< " -e, --exit-ignore-warnings - Exit with code 0 even if there are warnings\n"
<< " -f, --overwrite - Overwrite output file if it already exists\n"
<< " -g, --gdal-driver=DRIVER - GDAL driver (SQLite or ESRI Shapefile)\n"
<< " -l, --output-lines - Output coastlines as lines to database file\n"
Expand Down Expand Up @@ -99,6 +100,7 @@ int Options::parse(int argc, char* argv[]) {
{"close-distance", required_argument, nullptr, 'c'},
{"no-index", no_argument, nullptr, 'i'},
{"debug", no_argument, nullptr, 'd'},
{"exit-ignore-warnings", no_argument, nullptr, 'e'},
{"gdal-driver", required_argument, nullptr, 'g'},
{"help", no_argument, nullptr, 'h'},
{"output-lines", no_argument, nullptr, 'l'},
Expand All @@ -115,7 +117,7 @@ int Options::parse(int argc, char* argv[]) {
};

while (true) {
const int c = getopt_long(argc, argv, "b:c:idg:hlm:o:p:rfs:S:vV", long_options, nullptr);
const int c = getopt_long(argc, argv, "b:c:ideg:hlm:o:p:rfs:S:vV", long_options, nullptr);
if (c == -1) {
break;
}
Expand All @@ -134,6 +136,9 @@ int Options::parse(int argc, char* argv[]) {
debug = true;
std::cerr << "Enabled debug option\n";
break;
case 'e':
exit_ignore_warnings = true;
break;
case 'h':
print_help();
return return_code_ok;
Expand Down
3 changes: 3 additions & 0 deletions src/options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ struct Options {
/// Verbose output?
bool verbose = false;

/// Exit program with code 0 even if there are warnings?
bool exit_ignore_warnings = false;

/// Name of optional segment file
std::string segmentfile;

Expand Down
2 changes: 1 addition & 1 deletion src/osmcoastline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ int main(int argc, char *argv[]) {
return return_code_error;
}

if (warnings) {
if (warnings && !options.exit_ignore_warnings) {
return return_code_warning;
}

Expand Down

0 comments on commit d0ecd1e

Please sign in to comment.