mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Adds traceMode evaluator setting to support trace() pretty printing (#1100)
This commit is contained in:
@@ -22,6 +22,7 @@ import java.time.Duration
|
||||
import java.util.regex.Pattern
|
||||
import org.pkl.core.evaluatorSettings.Color
|
||||
import org.pkl.core.evaluatorSettings.PklEvaluatorSettings.ExternalReader
|
||||
import org.pkl.core.evaluatorSettings.TraceMode
|
||||
import org.pkl.core.module.ProjectDependenciesManager
|
||||
import org.pkl.core.util.IoUtils
|
||||
|
||||
@@ -148,6 +149,9 @@ data class CliBaseOptions(
|
||||
|
||||
/** External resource reader process specs */
|
||||
val externalResourceReaders: Map<String, ExternalReader> = mapOf(),
|
||||
|
||||
/** Defines options for the formatting of calls to the trace() method. */
|
||||
val traceMode: TraceMode? = null,
|
||||
) {
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.pkl.commons.cli.CliException
|
||||
import org.pkl.commons.shlex
|
||||
import org.pkl.core.evaluatorSettings.Color
|
||||
import org.pkl.core.evaluatorSettings.PklEvaluatorSettings.ExternalReader
|
||||
import org.pkl.core.evaluatorSettings.TraceMode
|
||||
import org.pkl.core.runtime.VmUtils
|
||||
import org.pkl.core.util.IoUtils
|
||||
|
||||
@@ -294,6 +295,17 @@ class BaseOptions : OptionGroup() {
|
||||
.multiple()
|
||||
.toMap()
|
||||
|
||||
val traceMode: TraceMode by
|
||||
option(
|
||||
names = arrayOf("--trace-mode"),
|
||||
metavar = "when",
|
||||
help =
|
||||
"Specifies how calls to trace() are formatted. Possible values of <when> are 'default', 'pretty' and 'hidden'.",
|
||||
)
|
||||
.enum<TraceMode> { it.name.lowercase() }
|
||||
.single()
|
||||
.default(TraceMode.DEFAULT)
|
||||
|
||||
// hidden option used by native tests
|
||||
private val testPort: Int by
|
||||
option(names = arrayOf("--test-port"), help = "Internal test option", hidden = true)
|
||||
@@ -331,6 +343,7 @@ class BaseOptions : OptionGroup() {
|
||||
httpRewrites = httpRewrites.ifEmpty { null },
|
||||
externalModuleReaders = externalModuleReaders,
|
||||
externalResourceReaders = externalResourceReaders,
|
||||
traceMode = traceMode,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user