44import org .utplsql .api .reporter .CoreReporters ;
55import org .utplsql .api .reporter .Reporter ;
66import org .utplsql .api .reporter .ReporterFactory ;
7+ import org .utplsql .cli .config .ReporterConfig ;
78import org .utplsql .cli .reporters .ReporterOptionsAware ;
89
910import javax .sql .DataSource ;
1314import java .sql .Connection ;
1415import java .sql .SQLException ;
1516import java .util .ArrayList ;
16- import java .util .Arrays ;
1717import java .util .List ;
1818import java .util .concurrent .ExecutorService ;
1919
@@ -23,17 +23,30 @@ class ReporterManager {
2323 private List <Throwable > reporterGatherErrors ;
2424 private ExecutorService executorService ;
2525
26- ReporterManager ( ReporterOptions [] reporterOptions ) {
27- this .reporterOptionsList = Arrays .asList (reporterOptions );
28- initReporterOptionsList ();
26+ ReporterManager (ReporterConfig [] reporterConfigs ) {
27+ reporterOptionsList = new ArrayList <>();
28+ if ( reporterConfigs != null && reporterConfigs .length > 0 ) {
29+ loadOptionsFromConfigs ( reporterConfigs );
30+ }
31+ else {
32+ reporterOptionsList .add (getDefaultReporterOption ());
33+ }
2934 }
3035
31- private void initReporterOptionsList ( ) {
36+ private void loadOptionsFromConfigs ( ReporterConfig [] reporterConfigs ) {
37+ boolean printToScreen = false ;
38+ for (ReporterConfig reporterConfig : reporterConfigs ) {
39+ ReporterOptions option = new ReporterOptions (
40+ reporterConfig .getName (),
41+ reporterConfig .getOutput ());
3242
33- // If no reporter parameters were passed, use default reporter.
34- if (reporterOptionsList .isEmpty ()) {
35- reporterOptionsList = new ArrayList <>();
36- reporterOptionsList .add (getDefaultReporterOption ());
43+ option .forceOutputToScreen (reporterConfig .isForceToScreen ());
44+ reporterOptionsList .add (option );
45+
46+ // Check printToScreen validity
47+ if (option .outputToScreen () && printToScreen )
48+ throw new IllegalArgumentException ("You cannot configure more than one reporter to output to screen" );
49+ printToScreen = option .outputToScreen ();
3750 }
3851 }
3952
0 commit comments