@@ -66,6 +66,7 @@ public static void main(String[] args) throws Exception {
6666
6767 boolean validArgs = true ;
6868 boolean overrideFutureDateError = false ;
69+ boolean reloadConfig = false ;
6970 if (args != null && args .length > 0 ) {
7071 try {
7172 Queue <String > argsQ = new LinkedList <String >(Arrays .asList (args ));
@@ -104,6 +105,7 @@ public static void main(String[] args) throws Exception {
104105 } else if (currArg .equalsIgnoreCase ("-p" )) {
105106 String value = argsQ .poll ();
106107 options .population = Integer .parseInt (value );
108+ Config .set ("generate.default_population" , value );
107109 } else if (currArg .equalsIgnoreCase ("-o" )) {
108110 String value = argsQ .poll ();
109111 options .overflow = Boolean .parseBoolean (value );
@@ -132,10 +134,7 @@ public static void main(String[] args) throws Exception {
132134 String value = argsQ .poll ();
133135 File configFile = new File (value );
134136 Config .load (configFile );
135- // Any options that are automatically set by reading the configuration
136- // file during options initialization need to be reset here.
137- options .population = Config .getAsInteger ("generate.default_population" , 1 );
138- options .threadPoolSize = Config .getAsInteger ("generate.thread_pool_size" , -1 );
137+ reloadConfig = true ;
139138 } else if (currArg .equalsIgnoreCase ("-d" )) {
140139 String value = argsQ .poll ();
141140 File localModuleDir = new File (value );
@@ -252,6 +251,7 @@ public static void main(String[] args) throws Exception {
252251 }
253252
254253 Config .set (configSetting , value );
254+ reloadConfig = true ;
255255 } else if (options .state == null ) {
256256 options .state = currArg ;
257257 } else {
@@ -266,12 +266,30 @@ public static void main(String[] args) throws Exception {
266266 }
267267 }
268268
269+ if (reloadConfig ) {
270+ resetOptionsFromConfig (options , exportOptions );
271+ }
272+
269273 if (validArgs && validateConfig (options , overrideFutureDateError )) {
270274 Generator generator = new Generator (options , exportOptions );
271275 generator .run ();
272276 }
273277 }
274278
279+ /**
280+ * Reset the fields of the provided options to the current values in the Config.
281+ */
282+ private static void resetOptionsFromConfig (Generator .GeneratorOptions options ,
283+ Exporter .ExporterRuntimeOptions exportOptions ) {
284+ // Any options that are automatically set by reading the configuration
285+ // file during options initialization need to be reset here.
286+ options .population = Config .getAsInteger ("generate.default_population" , 1 );
287+ options .threadPoolSize = Config .getAsInteger ("generate.thread_pool_size" , -1 );
288+
289+ exportOptions .yearsOfHistory = Config .getAsInteger ("exporter.years_of_history" , 10 );
290+ exportOptions .terminologyService = !Config .get ("generate.terminology_service_url" , "" ).isEmpty ();
291+ }
292+
275293 private static boolean validateConfig (Generator .GeneratorOptions options ,
276294 boolean overrideFutureDateError ) {
277295 boolean valid = true ;
0 commit comments