diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e94de15..d757155 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -30,7 +30,7 @@ xmlutil-serialization = { module = "io.github.pdvrieze.xmlutil:serialization", v mordant = "com.github.ajalt.mordant:mordant:2.7.2" tomlj = "org.tomlj:tomlj:1.1.1" -clikt = "com.github.ajalt.clikt:clikt:4.4.0" +clikt = "com.github.ajalt.clikt:clikt:5.0.0" junit = "junit:junit:4.13.2" truth = "com.google.truth:truth:1.4.4" diff --git a/src/main/kotlin/watch/dependency/main.kt b/src/main/kotlin/watch/dependency/main.kt index bb10e12..de3fa5f 100644 --- a/src/main/kotlin/watch/dependency/main.kt +++ b/src/main/kotlin/watch/dependency/main.kt @@ -3,7 +3,9 @@ package watch.dependency import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.Context import com.github.ajalt.clikt.core.NoOpCliktCommand +import com.github.ajalt.clikt.core.main import com.github.ajalt.clikt.core.subcommands import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.help @@ -39,10 +41,7 @@ fun main(vararg args: String) { .main(args) } -private abstract class DependencyWatchCommand( - name: String, - help: String = "", -) : CliktCommand(name = name, help = help) { +private abstract class DependencyWatchCommand(name: String) : CliktCommand(name) { protected val debug by option(hidden = true) .switch(mapOf("--debug" to Debug.Console)) .default(Debug.Disabled) @@ -108,11 +107,10 @@ private abstract class DependencyWatchCommand( ) } -private class AwaitCommand : - DependencyWatchCommand( - name = "await", - help = "Wait for an artifact to appear in a Maven repository then exit", - ) { +private class AwaitCommand : DependencyWatchCommand("await") { + override fun help(context: Context) = + "Wait for an artifact to appear in a Maven repository then exit" + private val repo by option("--repo", metavar = "URL") .help( """ @@ -156,10 +154,10 @@ private class AwaitCommand : private class NotifyCommand( fs: FileSystem, -) : DependencyWatchCommand( - name = "notify", - help = "Monitor Maven coordinates in a Maven repository for new versions", -) { +) : DependencyWatchCommand("notify") { + override fun help(context: Context) = + "Monitor Maven coordinates in a Maven repository for new versions" + private val configPath by argument("CONFIG") .help( """