Skip to content

Commit 892a2f0

Browse files
committed
Throw errors for some command line options values/combinations
Instead of just printing warnings. Warnings are in since at least 2.0.0 released in September 2024.
1 parent e9503a1 commit 892a2f0

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

src/command-line-parser.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,42 +137,42 @@ void check_options_non_slim(CLI::App const &app)
137137

138138
for (auto const &opt : slim_options) {
139139
if (app.count(opt) > 0) {
140-
log_warn("Ignoring option {}. Can only be used in --slim mode.",
141-
app.get_option(opt)->get_name(false, true));
140+
throw fmt_error("Option {} can only be used in --slim mode.",
141+
app.get_option(opt)->get_name(false, true));
142142
}
143143
}
144144
}
145145

146146
void check_options_output_flex(CLI::App const &app)
147147
{
148-
auto const ignored_options = app.get_options([](CLI::Option const *option) {
148+
auto const bad_options = app.get_options([](CLI::Option const *option) {
149149
return option->get_group() == "Pgsql output options" ||
150150
option->get_name() == "--tablespace-main-data" ||
151151
option->get_name() == "--tablespace-main-index";
152152
});
153153

154-
for (auto const *opt : ignored_options) {
154+
for (auto const *opt : bad_options) {
155155
if (opt->count()) {
156-
log_warn("Ignoring option {} for 'flex' output",
157-
opt->get_name(false, true));
156+
throw fmt_error("Option {} does not work with 'flex' output",
157+
opt->get_name(false, true));
158158
}
159159
}
160160
}
161161

162162
void check_options_output_null(CLI::App const &app)
163163
{
164-
auto const ignored_options = app.get_options([](CLI::Option const *option) {
164+
auto const bad_options = app.get_options([](CLI::Option const *option) {
165165
return option->get_group() == "Pgsql output options" ||
166166
option->get_group() == "Expire options" ||
167167
option->get_name() == "--style" ||
168168
option->get_name() == "--disable-parallel-indexing" ||
169169
option->get_name() == "--number-processes";
170170
});
171171

172-
for (auto const *opt : ignored_options) {
172+
for (auto const *opt : bad_options) {
173173
if (opt->count()) {
174-
log_warn("Ignoring option {} for 'null' output",
175-
opt->get_name(false, true));
174+
throw fmt_error("Option {} does not work with 'null' output",
175+
opt->get_name(false, true));
176176
}
177177
}
178178
}
@@ -208,8 +208,7 @@ void check_options(options_t *options)
208208
}
209209

210210
if (options->cache < 0) {
211-
options->cache = 0;
212-
log_warn("RAM cache cannot be negative. Using 0 instead.");
211+
throw std::runtime_error{"RAM cache cannot be negative."};
213212
}
214213

215214
if (options->cache == 0) {
@@ -244,9 +243,9 @@ void check_options_expire(options_t *options)
244243

245244
if (options->expire_tiles_zoom != 0 &&
246245
options->projection->target_srs() != PROJ_SPHERE_MERC) {
247-
log_warn("Expire has been enabled (with -e or --expire-tiles) but "
248-
"target SRS is not Mercator (EPSG:3857). Expire disabled!");
249-
options->expire_tiles_zoom = 0;
246+
throw std::runtime_error{
247+
"Expire has been enabled (with -e or --expire-tiles) but target "
248+
"SRS is not Mercator (EPSG:3857)"};
250249
}
251250
}
252251

0 commit comments

Comments
 (0)