Skip to content

Commit d0ecd1e

Browse files
committed
Add option -e, --exit-ignore-warnings
Return with exit code 0 even if there are warnings. Makes use in scripts simpler.
1 parent 0c2fca9 commit d0ecd1e

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

man/osmcoastline.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ description of the options below and the README.md for details.
4646
-d, \--debug
4747
: Enable debugging output.
4848

49+
-e, \--exit-ignore-warnings
50+
: Return with exit code 0 even if there are warnings.
51+
4952
-f, \--overwrite
5053
: Overwrite output file if it already exists.
5154

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

116119
1
117-
~ if there were warnings while processing the coastline
120+
~ if there were warnings while processing the coastline (unless -e is set)
118121

119122
2
120123
~ if there were errors while processing the coastline

src/options.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static void print_help() {
4444
<< " -b, --bbox-overlap=OVERLAP - Set overlap when splitting polygons\n"
4545
<< " -i, --no-index - Do not create spatial indexes in output db\n"
4646
<< " -d, --debug - Enable debugging output\n"
47+
<< " -e, --exit-ignore-warnings - Exit with code 0 even if there are warnings\n"
4748
<< " -f, --overwrite - Overwrite output file if it already exists\n"
4849
<< " -g, --gdal-driver=DRIVER - GDAL driver (SQLite or ESRI Shapefile)\n"
4950
<< " -l, --output-lines - Output coastlines as lines to database file\n"
@@ -99,6 +100,7 @@ int Options::parse(int argc, char* argv[]) {
99100
{"close-distance", required_argument, nullptr, 'c'},
100101
{"no-index", no_argument, nullptr, 'i'},
101102
{"debug", no_argument, nullptr, 'd'},
103+
{"exit-ignore-warnings", no_argument, nullptr, 'e'},
102104
{"gdal-driver", required_argument, nullptr, 'g'},
103105
{"help", no_argument, nullptr, 'h'},
104106
{"output-lines", no_argument, nullptr, 'l'},
@@ -115,7 +117,7 @@ int Options::parse(int argc, char* argv[]) {
115117
};
116118

117119
while (true) {
118-
const int c = getopt_long(argc, argv, "b:c:idg:hlm:o:p:rfs:S:vV", long_options, nullptr);
120+
const int c = getopt_long(argc, argv, "b:c:ideg:hlm:o:p:rfs:S:vV", long_options, nullptr);
119121
if (c == -1) {
120122
break;
121123
}
@@ -134,6 +136,9 @@ int Options::parse(int argc, char* argv[]) {
134136
debug = true;
135137
std::cerr << "Enabled debug option\n";
136138
break;
139+
case 'e':
140+
exit_ignore_warnings = true;
141+
break;
137142
case 'h':
138143
print_help();
139144
return return_code_ok;

src/options.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ struct Options {
9090
/// Verbose output?
9191
bool verbose = false;
9292

93+
/// Exit program with code 0 even if there are warnings?
94+
bool exit_ignore_warnings = false;
95+
9396
/// Name of optional segment file
9497
std::string segmentfile;
9598

src/osmcoastline.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ int main(int argc, char *argv[]) {
426426
return return_code_error;
427427
}
428428

429-
if (warnings) {
429+
if (warnings && !options.exit_ignore_warnings) {
430430
return return_code_warning;
431431
}
432432

0 commit comments

Comments
 (0)