Repository: apple/pkl
File: pkl-cli/src/main/kotlin/org/pkl/cli/commands/EvalCommand.kt (Kotlin)

Code before:
      .single()

  private val multipleFileOutputPath: String? by
    option(
        names = arrayOf("-m", "--multiple-file-output-path"),
        metavar = "path",
        help = "Directory where a module's multiple file output is placed.",
        completionCandidates = CompletionCandidates.Path,
      )
      .single()
      .validate {
        if (outputPath != null || expression != null) {
          fail("Option is mutually exclusive with -o, --output-path and -x, --expression.")
        }
      }

  // hidden option used by the native tests
  private val testMode: Boolean by
    option(names = arrayOf("--test-mode"), help = "Internal test mode", hidden = true).flag()

  private val powerAssertions: Boolean by
    option(
        names = arrayOf("--power-assertions"),
        help = "Enable power assertions for detailed assertion failure messages.",
      )
      .flag()

  override fun run() {
    val options =
      CliEvaluatorOptions(
        base =
          baseOptions.baseOptions(
            modules,
            projectOptions,
            testMode = testMode,
            powerAssertions = powerAssertions,
          ),
        outputPath = outputPath,
        outputFormat = baseOptions.format,
        moduleOutputSeparator = moduleOutputSeparator,
        multipleFileOutputPath = multipleFileOutputPath,
        expression = expression ?: CliEvaluatorOptions.defaults.expression,
      )
    CliEvaluator(options).run()
  }
}


Review comment (suggestion):
To ease copy/paste of options between test and eval commands, it might be nice to also support `--no-power-assertions` here

```suggestion
      .flag("--no-power-assertions", default = false, defaultForHelp = "disabled")
```

Code after:
      .single()

  private val multipleFileOutputPath: String? by
    option(
        names = arrayOf("-m", "--multiple-file-output-path"),
        metavar = "path",
        help = "Directory where a module's multiple file output is placed.",
        completionCandidates = CompletionCandidates.Path,
      )
      .single()
      .validate {
        if (outputPath != null || expression != null) {
          fail("Option is mutually exclusive with -o, --output-path and -x, --expression.")
        }
      }

  // hidden option used by the native tests
  private val testMode: Boolean by
    option(names = arrayOf("--test-mode"), help = "Internal test mode", hidden = true).flag()

  private val powerAssertionsEnabled: Boolean by
    option(
        names = arrayOf("--power-assertions"),
        help = "Enable power assertions for detailed assertion failure messages.",
      )
      .flag("--no-power-assertions", default = true, defaultForHelp = "enabled")

  override fun run() {
    val options =
      CliEvaluatorOptions(
        base =
          baseOptions.baseOptions(
            modules,
            projectOptions,
            testMode = testMode,
            powerAssertionsEnabled = powerAssertionsEnabled,
          ),
        outputPath = outputPath,
        outputFormat = baseOptions.format,
        moduleOutputSeparator = moduleOutputSeparator,
        multipleFileOutputPath = multipleFileOutputPath,
        expression = expression ?: CliEvaluatorOptions.defaults.expression,
      )
    CliEvaluator(options).run()
  }
}