Bump clikt to 5.0.3 (#947)

This bumps Clikt from version 3 to version 5, which, among other things, improves
the help text formatting with colors.

Also: 
* Add `--version` flag to pkldoc, pkl-codegen-java, pkl-codegen-kotlin
* Add help text to pkldoc, pkl-codegen-java, pkl-codegen-kotlin
This commit is contained in:
Artem Yarmoliuk
2025-02-19 23:18:02 +00:00
committed by GitHub
parent 643c6f5a76
commit 50cfb1c962
46 changed files with 461 additions and 226 deletions

View File

@@ -8,8 +8,26 @@ com.fasterxml.jackson.core:jackson-databind:2.18.2=testCompileClasspath,testImpl
com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.18.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.fasterxml.jackson:jackson-bom:2.18.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.github.ajalt.clikt:clikt-jvm:3.5.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.ajalt.clikt:clikt:3.5.4=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.github.ajalt.clikt:clikt-core-jvm:5.0.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.ajalt.clikt:clikt-core:5.0.3=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.github.ajalt.clikt:clikt-jvm:5.0.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.ajalt.clikt:clikt-markdown-jvm:5.0.3=runtimeClasspath,testRuntimeClasspath
com.github.ajalt.clikt:clikt-markdown:5.0.3=runtimeClasspath,testRuntimeClasspath
com.github.ajalt.clikt:clikt:5.0.3=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.github.ajalt.colormath:colormath-jvm:3.6.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.ajalt.colormath:colormath:3.6.0=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.github.ajalt.mordant:mordant-core-jvm:3.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.ajalt.mordant:mordant-core:3.0.1=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.github.ajalt.mordant:mordant-jvm-ffm-jvm:3.0.1=runtimeClasspath,testRuntimeClasspath
com.github.ajalt.mordant:mordant-jvm-ffm:3.0.1=runtimeClasspath,testRuntimeClasspath
com.github.ajalt.mordant:mordant-jvm-graal-ffi-jvm:3.0.1=runtimeClasspath,testRuntimeClasspath
com.github.ajalt.mordant:mordant-jvm-graal-ffi:3.0.1=runtimeClasspath,testRuntimeClasspath
com.github.ajalt.mordant:mordant-jvm-jna-jvm:3.0.1=runtimeClasspath,testRuntimeClasspath
com.github.ajalt.mordant:mordant-jvm-jna:3.0.1=runtimeClasspath,testRuntimeClasspath
com.github.ajalt.mordant:mordant-jvm:3.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.ajalt.mordant:mordant-markdown-jvm:3.0.1=runtimeClasspath,testRuntimeClasspath
com.github.ajalt.mordant:mordant-markdown:3.0.1=runtimeClasspath,testRuntimeClasspath
com.github.ajalt.mordant:mordant:3.0.1=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.github.jknack:handlebars-helpers:4.3.1=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.github.jknack:handlebars:4.3.1=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.36.0=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
@@ -22,6 +40,7 @@ com.networknt:json-schema-validator:1.5.5=testCompileClasspath,testImplementatio
commons-fileupload:commons-fileupload:1.5=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
commons-io:commons-io:2.11.0=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.14.0=runtimeClasspath,testRuntimeClasspath
net.javacrumbs.json-unit:json-unit-core:2.40.1=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.minidev:accessors-smart:2.5.1=testRuntimeClasspath
net.minidev:json-smart:2.5.1=testRuntimeClasspath
@@ -80,18 +99,19 @@ org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-reflect:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinCompilerPluginClasspathTestJdk17,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinCompilerPluginClasspathTestJdk17
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinCompilerPluginClasspathTestJdk17
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinCompilerPluginClasspathTestJdk17
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinCompilerPluginClasspathTestJdk17
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinCompilerPluginClasspathTestJdk17,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinCompilerPluginClasspathTestJdk17,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains:markdown-jvm:0.7.3=runtimeClasspath,testRuntimeClasspath
org.jetbrains:markdown:0.7.3=runtimeClasspath,testRuntimeClasspath
org.jline:jline-native:3.23.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jline:jline-reader:3.23.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jline:jline-terminal-jansi:3.23.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath

View File

@@ -68,11 +68,7 @@ dependencies {
implementation(libs.jlineTerminal)
implementation(libs.jlineTerminalJansi)
implementation(projects.pklServer)
implementation(libs.clikt) {
// force clikt to use our version of the kotlin stdlib
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common")
}
implementation(libs.clikt)
testImplementation(projects.pklCommonsTest)
testImplementation(libs.wiremock)

View File

@@ -51,9 +51,9 @@ constructor(
// keep in sync with error message thrown by clikt
throw CliException(
"""
Usage: pkl test [OPTIONS] <modules>...
Usage: pkl test [<options>] <modules>...
Error: Missing argument "<modules>"
Error: missing argument <modules>
"""
.trimIndent()
)

View File

@@ -17,6 +17,7 @@
package org.pkl.cli
import com.github.ajalt.clikt.core.main
import org.pkl.cli.commands.*
import org.pkl.commons.cli.cliMain

View File

@@ -15,6 +15,7 @@
*/
package org.pkl.cli.commands
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.options.option
@@ -25,28 +26,23 @@ import org.pkl.cli.CliImportAnalyzerOptions
import org.pkl.commons.cli.commands.ModulesCommand
import org.pkl.commons.cli.commands.single
class AnalyzeCommand :
NoOpCliktCommand(
name = "analyze",
help = "Commands related to static analysis",
epilog = "For more information, visit $helpLink",
) {
class AnalyzeCommand : NoOpCliktCommand(name = "analyze") {
override fun help(context: Context) = "Commands related to static analysis"
override fun helpEpilog(context: Context) = "For more information, visit $helpLink"
init {
subcommands(AnalyzeImportsCommand())
}
}
class AnalyzeImportsCommand :
ModulesCommand(
name = "imports",
helpLink = helpLink,
help = "Prints the graph of modules imported by the input module(s).",
) {
class AnalyzeImportsCommand : ModulesCommand(name = "imports", helpLink = helpLink) {
override val helpString = "Prints the graph of modules imported by the input module(s)."
private val outputPath: Path? by
option(
names = arrayOf("-o", "--output-path"),
metavar = "<path>",
metavar = "path",
help = "File path where the output file is placed.",
)
.path()

View File

@@ -27,29 +27,27 @@ import org.pkl.commons.cli.commands.ProjectOptions
import org.pkl.commons.cli.commands.single
import org.pkl.core.packages.PackageUri
class DownloadPackageCommand :
BaseCommand(
name = "download-package",
helpLink = helpLink,
help =
"""
Download package(s)
This command downloads the specified packages to the cache directory.
If the package already exists in the cache directory, this command is a no-op.
Examples:
```
# Download two packages
$ pkl download-package package://example.com/package1@1.0.0 package://example.com/package2@1.0.0
```
class DownloadPackageCommand : BaseCommand(name = "download-package", helpLink = helpLink) {
override val helpString =
"""
Download package(s)
This command downloads the specified packages to the cache directory.
If the package already exists in the cache directory, this command is a no-op.
Examples:
```
# Download two packages
$ pkl download-package package://example.com/package1@1.0.0 package://example.com/package2@1.0.0
```
"""
.trimIndent(),
) {
.trimIndent()
private val projectOptions by ProjectOptions()
private val packageUris: List<PackageUri> by
argument("<package>", "The package URIs to download")
argument("package", "The package URIs to download")
.convert { PackageUri(it) }
.multiple(required = true)

View File

@@ -24,12 +24,14 @@ import org.pkl.cli.CliEvaluatorOptions
import org.pkl.commons.cli.commands.ModulesCommand
import org.pkl.commons.cli.commands.single
class EvalCommand :
ModulesCommand(name = "eval", help = "Render pkl module(s)", helpLink = helpLink) {
class EvalCommand : ModulesCommand(name = "eval", helpLink = helpLink) {
override val helpString = "Render pkl module(s)"
private val outputPath: String? by
option(
names = arrayOf("-o", "--output-path"),
metavar = "<path>",
metavar = "path",
help = "File path where the output file is placed.",
)
.single()
@@ -37,7 +39,7 @@ class EvalCommand :
private val moduleOutputSeparator: String by
option(
names = arrayOf("--module-output-separator"),
metavar = "<string>",
metavar = "string",
help =
"Separator to use when multiple module outputs are written to the same file. (default: ---)",
)
@@ -47,7 +49,7 @@ class EvalCommand :
private val expression: String? by
option(
names = arrayOf("-x", "--expression"),
metavar = "<expression>",
metavar = "expression",
help = "Expression to be evaluated within the module.",
)
.single()
@@ -55,7 +57,7 @@ class EvalCommand :
private val multipleFileOutputPath: String? by
option(
names = arrayOf("-m", "--multiple-file-output-path"),
metavar = "<path>",
metavar = "path",
help = "Directory where a module's multiple file output is placed.",
)
.single()

View File

@@ -15,6 +15,7 @@
*/
package org.pkl.cli.commands
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.arguments.argument
@@ -33,95 +34,88 @@ import org.pkl.commons.cli.commands.single
private const val NEWLINE = '\u0085'
class ProjectCommand :
NoOpCliktCommand(
name = "project",
help = "Run commands related to projects",
epilog = "For more information, visit $helpLink",
) {
class ProjectCommand : NoOpCliktCommand(name = "project") {
override fun help(context: Context) = "Run commands related to projects"
override fun helpEpilog(context: Context) = "For more information, visit $helpLink"
init {
subcommands(ResolveCommand(), PackageCommand())
}
}
class ResolveCommand :
BaseCommand(
name = "resolve",
helpLink = helpLink,
help =
"""
Resolve dependencies for project(s)
This command takes the `dependencies` of `PklProject`s, and writes the
resolved versions to `PklProject.deps.json` files.
Examples:
class ResolveCommand : BaseCommand(name = "resolve", helpLink = helpLink) {
override val helpString =
"""
Resolve dependencies for project(s)
```
# Search the current working directory for a project, and resolve its dependencies.
$ pkl project resolve
This command takes the `dependencies` of `PklProject`s, and writes the
resolved versions to `PklProject.deps.json` files.
Examples:
```
# Search the current working directory for a project, and resolve its dependencies.
$ pkl project resolve
# Resolve dependencies for all projects within the `packages/` directory.
$ pkl project resolve packages/*/
```
"""
# Resolve dependencies for all projects within the `packages/` directory.
$ pkl project resolve packages/*/
```
""",
) {
private val projectDirs: List<Path> by
argument("<dir>", "The project directories to resolve dependencies for").path().multiple()
argument("dir", "The project directories to resolve dependencies for").path().multiple()
override fun run() {
CliProjectResolver(baseOptions.baseOptions(emptyList()), projectDirs).run()
}
}
class PackageCommand :
BaseCommand(
name = "package",
helpLink = helpLink,
help =
"""
Verify package(s), and prepare package artifacts to be published.
class PackageCommand : BaseCommand(name = "package", helpLink = helpLink) {
override val helpString =
"""
Verify package(s), and prepare package artifacts to be published.
This command runs a project's api tests, as defined by `apiTests` in `PklProject`.
Additionally, it verifies that all imports resolve to paths that are local to the project.
This command runs a project's api tests, as defined by `apiTests` in `PklProject`.
Additionally, it verifies that all imports resolve to paths that are local to the project.
Finally, this command writes the following artifacts into the output directory specified by the output path.
Finally, this command writes the following artifacts into the output directory specified by the output path.
- `name@version` - dependency metadata$NEWLINE
- `name@version.sha256` - dependency metadata's SHA-256 checksum$NEWLINE
- `name@version.zip` - package archive$NEWLINE
- `name@version.zip.sha256` - package archive's SHA-256 checksum
- `name@version` - dependency metadata$NEWLINE
- `name@version.sha256` - dependency metadata's SHA-256 checksum$NEWLINE
- `name@version.zip` - package archive$NEWLINE
- `name@version.zip.sha256` - package archive's SHA-256 checksum
The output path option accepts the following placeholders:
The output path option accepts the following placeholders:
- %{name}: The display name of the package$NEWLINE
- %{version}: The version of the package
- %{name}: The display name of the package$NEWLINE
- %{version}: The version of the package
If a project has local project dependencies, the depended upon project directories must also
be included as arguments to this command.
If a project has local project dependencies, the depended upon project directories must also
be included as arguments to this command.
Examples:
Examples:
```
# Search the current working directory for a project, and package it.
$ pkl project package
```
# Search the current working directory for a project, and package it.
$ pkl project package
# Package all projects within the `packages/` directory.
$ pkl project package packages/*/
```
"""
.trimIndent()
# Package all projects within the `packages/` directory.
$ pkl project package packages/*/
```
"""
.trimIndent(),
) {
private val testOptions by TestOptions()
private val projectDirs: List<Path> by
argument("<dir>", "The project directories to package").path().multiple()
argument("dir", "The project directories to package").path().multiple()
private val outputPath: String by
option(
names = arrayOf("--output-path"),
help = "The directory to write artifacts to",
metavar = "<path>",
metavar = "path",
)
.single()
.default(".out/%{name}@%{version}")

View File

@@ -21,7 +21,9 @@ import org.pkl.cli.CliRepl
import org.pkl.commons.cli.commands.BaseCommand
import org.pkl.commons.cli.commands.ProjectOptions
class ReplCommand : BaseCommand(name = "repl", help = "Start a REPL session", helpLink = helpLink) {
class ReplCommand : BaseCommand(name = "repl", helpLink = helpLink) {
override val helpString = "Start a REPL session"
private val projectOptions by ProjectOptions()
override fun run() {

View File

@@ -15,31 +15,31 @@
*/
package org.pkl.cli.commands
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.core.context
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.options.versionOption
import org.pkl.commons.cli.commands.installCommonOptions
import org.pkl.core.Release
internal val helpLink = "${Release.current().documentation.homepage}pkl-cli/index.html#usage"
class RootCommand :
NoOpCliktCommand(
name = "pkl",
printHelpOnEmptyArgs = true,
epilog = "For more information, visit $helpLink",
) {
init {
versionOption(Release.current().versionInfo, names = setOf("-v", "--version"), message = { it })
class RootCommand : NoOpCliktCommand(name = "pkl") {
override val printHelpOnEmptyArgs = true
override fun helpEpilog(context: Context) = "For more information, visit $helpLink"
init {
context {
correctionSuggestor = { given, possible ->
suggestTypoCorrection = { given, possible ->
if (!given.startsWith("-")) {
registeredSubcommands().map { it.commandName }
} else possible
}
}
installCommonOptions()
subcommands(
EvalCommand(),
ReplCommand(),

View File

@@ -16,15 +16,15 @@
package org.pkl.cli.commands
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import org.pkl.cli.CliServer
import org.pkl.commons.cli.CliBaseOptions
class ServerCommand :
CliktCommand(
name = "server",
help = "Run as a server that communicates over standard input/output",
epilog = "For more information, visit $helpLink",
) {
class ServerCommand : CliktCommand(name = "server") {
override fun help(context: Context) =
"Run as a server that communicates over standard input/output"
override fun helpEpilog(context: Context) = "For more information, visit $helpLink"
override fun run() {
CliServer(CliBaseOptions()).run()

View File

@@ -26,10 +26,11 @@ import org.pkl.commons.cli.commands.BaseOptions
import org.pkl.commons.cli.commands.ProjectOptions
import org.pkl.commons.cli.commands.TestOptions
class TestCommand :
BaseCommand(name = "test", help = "Run tests within the given module(s)", helpLink = helpLink) {
class TestCommand : BaseCommand(name = "test", helpLink = helpLink) {
override val helpString = "Run tests within the given module(s)"
val modules: List<URI> by
argument(name = "<modules>", help = "Module paths or URIs to evaluate.")
argument(name = "modules", help = "Module paths or URIs to evaluate.")
.convert { BaseOptions.parseModuleName(it) }
.multiple()

View File

@@ -16,6 +16,8 @@
package org.pkl.cli
import com.github.ajalt.clikt.core.BadParameterValue
import com.github.ajalt.clikt.core.CliktError
import com.github.ajalt.clikt.core.parse
import java.nio.file.Path
import kotlin.io.path.createDirectory
import kotlin.io.path.createSymbolicLinkPointingTo
@@ -43,17 +45,20 @@ class CliMainTest {
arrayOf("eval", "--output-path", "path1", "--output-path", "path2", inputFile)
)
}
.hasMessage("Invalid value for \"--output-path\": Option cannot be repeated")
.hasMessage("Option cannot be repeated")
assertThatCode {
rootCmd.parse(arrayOf("eval", "-o", "path1", "--output-path", "path2", inputFile))
}
.hasMessage("Invalid value for \"--output-path\": Option cannot be repeated")
.hasMessage("Option cannot be repeated")
}
@Test
fun `eval requires at least one file`() {
assertThatCode { rootCmd.parse(arrayOf("eval")) }.hasMessage("""Missing argument "<modules>"""")
assertThatCode { rootCmd.parse(arrayOf("eval")) }
.isInstanceOf(CliktError::class.java)
.extracting("paramName")
.isEqualTo("modules")
}
// Can't reliably create symlinks on Windows.
@@ -82,8 +87,7 @@ class CliMainTest {
fun `cannot have multiple output with -o or -x`(@TempDir tempDir: Path) {
val testIn = makeInput(tempDir)
val testOut = tempDir.resolve("test").toString()
val error =
"""Invalid value for "--multiple-file-output-path": Option is mutually exclusive with -o, --output-path and -x, --expression."""
val error = """Option is mutually exclusive with -o, --output-path and -x, --expression."""
assertThatCode { rootCmd.parse(arrayOf("eval", "-m", testOut, "-x", "x", testIn)) }
.hasMessage(error)

View File

@@ -15,7 +15,7 @@
*/
package org.pkl.cli
import com.github.ajalt.clikt.core.MissingArgument
import com.github.ajalt.clikt.testing.test
import java.io.StringWriter
import java.io.Writer
import java.net.URI
@@ -388,9 +388,9 @@ class CliTestRunnerTest {
@Test
fun `no source modules specified has same message as pkl eval`() {
val e1 = assertThrows<CliException> { CliTestRunner(CliBaseOptions(), CliTestOptions()).run() }
val e2 = assertThrows<MissingArgument> { RootCommand().parse(listOf("eval")) }
assertThat(e1).hasMessageContaining("Missing argument \"<modules>\"")
assertThat(e1.message!!.replace("test", "eval")).isEqualTo(e2.helpMessage())
val e2 = RootCommand().test("eval")
assertThat(e1).hasMessageContaining("missing argument <modules>")
assertThat(e1.message!!.replace("test", "eval") + "\n").isEqualTo(e2.stderr)
}
@Test