@@ -79,7 +79,7 @@ static void print_modified_quicktune_values();
79
79
80
80
static void list_game_ids ();
81
81
static void list_worlds (bool print_name, bool print_path);
82
- static void setup_log_params (const Settings &cmd_args);
82
+ static bool setup_log_params (const Settings &cmd_args);
83
83
static bool create_userdata_path ();
84
84
static bool init_common (const Settings &cmd_args, int argc, char *argv[]);
85
85
static void startup_message ();
@@ -135,7 +135,8 @@ int main(int argc, char *argv[])
135
135
return 0 ;
136
136
}
137
137
138
- setup_log_params (cmd_args);
138
+ if (!setup_log_params (cmd_args))
139
+ return 1 ;
139
140
140
141
porting::signal_handler_init ();
141
142
@@ -166,8 +167,12 @@ int main(int argc, char *argv[])
166
167
list_worlds (true , false );
167
168
} else if (cmd_args.get (" worldlist" ) == " path" ) {
168
169
list_worlds (false , true );
169
- } else {
170
+ } else if (cmd_args. get ( " worldlist " ) == " both " ) {
170
171
list_worlds (true , true );
172
+ } else {
173
+ errorstream << " Invalid --worldlist value: "
174
+ << cmd_args.get (" worldlist" ) << std::endl;
175
+ return 1 ;
171
176
}
172
177
return 0 ;
173
178
}
@@ -258,23 +263,17 @@ static void set_allowed_options(OptionList *allowed_options)
258
263
allowed_options->insert (std::make_pair (" map-dir" , ValueSpec (VALUETYPE_STRING,
259
264
_ (" Same as --world (deprecated)" ))));
260
265
allowed_options->insert (std::make_pair (" world" , ValueSpec (VALUETYPE_STRING,
261
- _ (" Set world path (implies local game)" ))));
266
+ _ (" Set world path (implies local game if used with option --go )" ))));
262
267
allowed_options->insert (std::make_pair (" worldname" , ValueSpec (VALUETYPE_STRING,
263
- _ (" Set world by name (implies local game)" ))));
268
+ _ (" Set world by name (implies local game if used with option --go )" ))));
264
269
allowed_options->insert (std::make_pair (" worldlist" , ValueSpec (VALUETYPE_STRING,
265
- _ (" Get list of worlds (implies local game) ( 'path' lists paths, "
270
+ _ (" Get list of worlds ('path' lists paths, "
266
271
" 'name' lists names, 'both' lists both)" ))));
267
272
allowed_options->insert (std::make_pair (" quiet" , ValueSpec (VALUETYPE_FLAG,
268
273
_ (" Print to console errors only" ))));
269
- #if !defined(_WIN32)
270
274
allowed_options->insert (std::make_pair (" color" , ValueSpec (VALUETYPE_STRING,
271
275
_ (" Coloured logs ('always', 'never' or 'auto'), defaults to 'auto'"
272
276
))));
273
- #else
274
- allowed_options->insert (std::make_pair (" color" , ValueSpec (VALUETYPE_STRING,
275
- _ (" Coloured logs ('always' or 'never'), defaults to 'never'"
276
- ))));
277
- #endif
278
277
allowed_options->insert (std::make_pair (" info" , ValueSpec (VALUETYPE_FLAG,
279
278
_ (" Print more information to console" ))));
280
279
allowed_options->insert (std::make_pair (" verbose" , ValueSpec (VALUETYPE_FLAG,
@@ -398,7 +397,7 @@ static void print_modified_quicktune_values()
398
397
}
399
398
}
400
399
401
- static void setup_log_params (const Settings &cmd_args)
400
+ static bool setup_log_params (const Settings &cmd_args)
402
401
{
403
402
// Quiet mode, print errors only
404
403
if (cmd_args.getFlag (" quiet" )) {
@@ -418,14 +417,16 @@ static void setup_log_params(const Settings &cmd_args)
418
417
#endif
419
418
}
420
419
if (color_mode != " " ) {
421
- if (color_mode == " auto" )
420
+ if (color_mode == " auto" ) {
422
421
Logger::color_mode = LOG_COLOR_AUTO;
423
- else if (color_mode == " always" )
422
+ } else if (color_mode == " always" ) {
424
423
Logger::color_mode = LOG_COLOR_ALWAYS;
425
- else if (color_mode == " never" )
424
+ } else if (color_mode == " never" ) {
426
425
Logger::color_mode = LOG_COLOR_NEVER;
427
- else
426
+ } else {
428
427
errorstream << " Invalid color mode: " << color_mode << std::endl;
428
+ return false ;
429
+ }
429
430
}
430
431
431
432
// If trace is enabled, enable logging of certain things
@@ -444,6 +445,8 @@ static void setup_log_params(const Settings &cmd_args)
444
445
// In certain cases, output verbose level on stderr
445
446
if (cmd_args.getFlag (" verbose" ) || cmd_args.getFlag (" trace" ))
446
447
g_logger.addOutput (&stderr_output, LL_VERBOSE);
448
+
449
+ return true ;
447
450
}
448
451
449
452
static bool create_userdata_path ()
0 commit comments