stevedlawrence commented on code in PR #875:
URL: https://github.com/apache/daffodil/pull/875#discussion_r1025167136


##########
daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala:
##########
@@ -929,7 +930,7 @@ object Main {
 
             processor = processor.withValidationMode(validate)
 
-            setupDebugOrTrace(processor.asInstanceOf[DataProcessor], conf)
+            val debugProcessor = 
setupDebugOrTrace(processor.asInstanceOf[DataProcessor], conf)

Review Comment:
   Yeah, the var approach seems reasonable to me in this case. Especially since 
`debugProcessor` might not even have debugging enabled depending on the provide 
conf options, so it could potentially be confusing. It's more like 
`maybeDebugProcessor` which is ugly and still confusing.
   
   An alternative, though maybe a bit more invasive, might be to do what we do 
with the performance command, which looks like this:
   
   ```scala
           val processor = {
             if (performanceOpts.parser.isDefined) {
               createProcessorFromParser(performanceOpts.parser(), 
performanceOpts.path.toOption, validate)
             } else {
               val tunables = 
DaffodilTunables.configPlusMoreTunablesMap(performanceOpts.tunables, 
optDafConfig)
               createProcessorFromSchema(performanceOpts.schema(), 
performanceOpts.rootNS.toOption, performanceOpts.path.toOption, tunables, 
validate)
             }
           }.map{ 
_.withExternalVariables(combineExternalVariables(performanceOpts.vars, 
optDafConfig)) }
            .map{ _.withValidationMode(validate) }
   ```
   We could just add a `.map { withDebugOrTrace(_, conf) }` to the end of that.
   
   This way all processor setup happens in one spot for each subcommand, the 
processor variable can always be a val, and is consistent among the different 
subcommands.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to