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
@@ -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)
@@ -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