@@ -21,6 +21,8 @@ import scala.jdk.CollectionConverters.*
2121import PolystatConfig .*
2222import SupportedLanguage .*
2323import IncludeExclude .*
24+ import org .polystat .cli .util .FileTypes .*
25+ import ciris .ConfigKey
2426
2527case class HoconConfig (path : Path ):
2628
@@ -33,7 +35,7 @@ case class HoconConfig(path: Path):
3335 val loadConfig : IO [Config ] =
3436 IO .blocking(ConfigFactory .parseFile(path.toNioPath.toFile))
3537
36- val parseConfig : IO [ConfigValue [IO , PolystatUsage .Analyze ]] =
38+ val parseConfig : IO [ConfigValue [IO , IO [ PolystatUsage .Analyze ] ]] =
3739 loadConfig.map(parsed =>
3840 given Config = parsed
3941 val lang = hocon(keys.inputLanguage).as[SupportedLanguage ]
@@ -50,10 +52,15 @@ case class HoconConfig(path: Path):
5052 val outputsConsole =
5153 hocon(keys.outputsConsole).as[Boolean ].default(false )
5254
53- val outputs = (outputsDirs, outputsFiles, outputsConsole).parMapN {
54- case (dirs, files, console) =>
55- Output (dirs = dirs, files = files, console = console)
56- }
55+ val outputs : ConfigValue [IO , IO [Output ]] =
56+ (outputsDirs, outputsFiles, outputsConsole).parMapN {
57+ case (dirs, files, console) =>
58+ for
59+ dirs <- dirs.traverse(Directory .fromPathFailFast)
60+ files <- files.traverse(File .fromPathFailFast)
61+ yield Output (dirs = dirs, files = files, console = console)
62+
63+ }
5764
5865 val j2eoVersion = hocon(keys.j2eoVersion).as[String ].option
5966 val outputFormats =
@@ -77,7 +84,11 @@ case class HoconConfig(path: Path):
7784 outputFormats,
7885 lang,
7986 ) =>
80- PolystatUsage .Analyze (
87+ for
88+ j2eo <- j2eo.traverse(File .fromPathFailFast)
89+ tmp <- tmp.traverse(Directory .fromPathFailFast)
90+ outputs <- outputs
91+ yield PolystatUsage .Analyze (
8192 language = lang match
8293 case Java (_, _) => Java (j2eo, j2eoVersion)
8394 case other => other
@@ -94,7 +105,14 @@ case class HoconConfig(path: Path):
94105 )
95106 end parseConfig
96107
97- ConfigValue .eval(parseConfig)
108+ for
109+ parsed <- ConfigValue .eval(parseConfig)
110+ validated <- ConfigValue .eval(
111+ parsed.map(validated =>
112+ ConfigValue .loaded(ConfigKey (keys.toplevel), validated)
113+ )
114+ )
115+ yield validated
98116 end config
99117
100118end HoconConfig
0 commit comments