@@ -67,6 +67,8 @@ object PGo {
6767 s " missing or incorrect prefix for $str" ,
6868 )
6969
70+ final case class ConfigExit (code : Int ) extends RuntimeException
71+
7072 class Config (arguments : Seq [String ]) extends ScallopConf (arguments) {
7173 banner(" PGo compiler" )
7274
@@ -282,6 +284,13 @@ object PGo {
282284 descr = " directory containing log files to use" ,
283285 default = Some (destDir()),
284286 )
287+ validate(logsDir): logsDir =>
288+ if os.list(logsDir).filter(_.last.endsWith(" .log" )).isEmpty
289+ then
290+ Left (
291+ s " $logsDir has no .log files - you need to pass a folder formatted as if harvest-traces generated it " ,
292+ )
293+ else Right (())
285294 val cfgFragmentSuffix = opt[String ](
286295 descr =
287296 " suffix to add to {model_name}Validate{suffix}.cfg, when looking for a manual config file" ,
@@ -438,7 +447,7 @@ object PGo {
438447 println(s " $printedName: $line" )
439448 }
440449 printHelp()
441- sys.exit (1 )
450+ throw ConfigExit (1 )
442451 }
443452
444453 verify()
@@ -560,7 +569,10 @@ object PGo {
560569
561570 def main (args : Array [String ]): Unit = {
562571 val startTime = System .currentTimeMillis()
563- val errors = run(ArraySeq .unsafeWrapArray(args))
572+ val errors = try
573+ run(ArraySeq .unsafeWrapArray(args))
574+ catch case ConfigExit (code) =>
575+ sys.exit(code)
564576 val endTime = System .currentTimeMillis()
565577 val duration = Duration (length = endTime - startTime, unit = MILLISECONDS )
566578 if (errors.nonEmpty) {
0 commit comments