Skip to content

Commit bd4cb25

Browse files
committed
enforces that no other config options are provided when using
1 parent e272d9c commit bd4cb25

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/scala/viper/gobra/frontend/Config.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ class ScallopGobraConfig(arguments: Seq[String], isInputOptional: Boolean = fals
771771

772772
val configFile: ScallopOption[File] = opt[File](
773773
name = "config",
774-
descr = "Reads all configuration options from the provided JSON file. Any other CLI option will be ignored.",
774+
descr = "Reads all configuration options from the provided JSON file.",
775775
noshort = true
776776
)
777777

@@ -1097,6 +1097,12 @@ class ScallopGobraConfig(arguments: Seq[String], isInputOptional: Boolean = fals
10971097
// Thus, we restrict their use:
10981098
conflicts(input, List(projectRoot, inclPackages, exclPackages))
10991099
conflicts(directory, List(inclPackages, exclPackages))
1100+
// to check that no further config options get provided when using `configFile`, we have to use reflection to obtain
1101+
// all ScallopOptions as Scallop does not seem to provide any built-in functionality to achieve the same:
1102+
val allOptions = getClass.getDeclaredFields
1103+
.map(_.get(this)) // get field value
1104+
.collect { case o: ScallopOption[_] => o } // filter by ScallopOption
1105+
conflicts(configFile, allOptions.toList.filterNot(_ == configFile))
11001106

11011107
// must be a function or lazy to guarantee that this value is computed only during the CLI options validation and not before.
11021108
private def isSiliconBasedBackend = backend.toOption.getOrElse(ConfigDefaults.DefaultBackend) match {

0 commit comments

Comments
 (0)