mirror of
https://github.com/apple/pkl.git
synced 2026-04-23 00:38:37 +02:00
Turn CLI commands into objects, self register subcommands (#935)
Usages of `RootCommand` no longer need to initialize a new instance, nor register subcommands.
This commit is contained in:
@@ -34,10 +34,10 @@ import org.pkl.core.Release
|
||||
|
||||
/** Main method for the Pkldoc CLI. */
|
||||
internal fun main(args: Array<String>) {
|
||||
cliMain { DocCommand().main(args) }
|
||||
cliMain { DocCommand.main(args) }
|
||||
}
|
||||
|
||||
class DocCommand :
|
||||
object DocCommand :
|
||||
BaseCommand(name = "pkldoc", helpLink = Release.current().documentation().homepage()) {
|
||||
|
||||
private val modules: List<URI> by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,12 +21,9 @@ import org.junit.jupiter.api.assertThrows
|
||||
import org.pkl.commons.cli.CliException
|
||||
|
||||
class CliMainTest {
|
||||
|
||||
private val docCommand = DocCommand()
|
||||
|
||||
@Test
|
||||
fun `CLI run test`() {
|
||||
val e = assertThrows<CliException> { docCommand.parse(arrayOf("foo", "--output-dir", "/tmp")) }
|
||||
val e = assertThrows<CliException> { DocCommand.parse(arrayOf("foo", "--output-dir", "/tmp")) }
|
||||
assertThat(e)
|
||||
.hasMessageContaining("must contain at least one module named `doc-package-info.pkl`")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user