@@ -418,6 +418,15 @@ def main():
418418 for err in options .update_config (site_config ):
419419 printer .warning (str (err ))
420420
421+ # Update options from the selected execution mode
422+ if options .mode :
423+ mode_args = site_config .get (f'modes/@{ options .mode } /options' )
424+
425+ # Parse the mode's options and reparse the command-line
426+ options = argparser .parse_args (mode_args )
427+ options = argparser .parse_args (namespace = options .cmd_options )
428+ options .update_config (site_config )
429+
421430 logging .configure_logging (site_config )
422431 except (OSError , ConfigError ) as e :
423432 printer .error (f'failed to load configuration: { e } ' )
@@ -447,18 +456,6 @@ def main():
447456 printer .error ('could not load module mappings: %s' % e )
448457 sys .exit (1 )
449458
450- if options .mode :
451- try :
452- mode_args = rt .get_option (f'modes/@{ options .mode } /options' )
453-
454- # Parse the mode's options and reparse the command-line
455- options = argparser .parse_args (mode_args )
456- options = argparser .parse_args (namespace = options .cmd_options )
457- options .update_config (rt .site_config )
458- except ConfigError as e :
459- printer .error ('could not obtain execution mode: %s' % e )
460- sys .exit (1 )
461-
462459 if (os_ext .samefile (rt .stage_prefix , rt .output_prefix ) and
463460 not site_config .get ('general/0/keep_stage_files' )):
464461 printer .error ("stage and output refer to the same directory; "
0 commit comments