feat(partnerctl): add shared help option mixin across commands

This commit is contained in:
2026-05-06 15:06:20 +08:00
parent 442397c1f5
commit 7bee14452e
8 changed files with 35 additions and 0 deletions

View File

@@ -14,6 +14,9 @@ import picocli.CommandLine
)
class ChatCommand : Runnable {
@CommandLine.Mixin
lateinit var helpOptions: HelpOptions
override fun run() {
val terminal = createTerminal()
val reader = LineReaderBuilder.builder()

View File

@@ -8,6 +8,10 @@ import picocli.CommandLine
description = [$$"${bundle:cli.config.description}"],
)
class ConfigCommand : Runnable{
@CommandLine.Mixin
lateinit var helpOptions: HelpOptions
override fun run() {
TODO("Not yet implemented")
}

View File

@@ -0,0 +1,12 @@
package work.slhaf.partner.ctl.commands
import picocli.CommandLine
class HelpOptions {
@CommandLine.Option(
names = ["-h", "--help"],
usageHelp = true,
descriptionKey = "cli.option.help.description",
)
var help: Boolean = false
}

View File

@@ -27,6 +27,9 @@ import java.nio.file.Paths
)
class InitCommand : Runnable {
@CommandLine.Mixin
lateinit var helpOptions: HelpOptions
lateinit var home: Path
/**

View File

@@ -14,6 +14,9 @@ import java.nio.file.Path
)
class LogCommand : Runnable {
@CommandLine.Mixin
lateinit var helpOptions: HelpOptions
@CommandLine.Option(
names = ["--tail"],
descriptionKey = "cli.log.option.tail.description",

View File

@@ -8,6 +8,10 @@ import picocli.CommandLine
description = [$$"${bundle:cli.module.description}"],
)
class ModuleCommand : Runnable{
@CommandLine.Mixin
lateinit var helpOptions: HelpOptions
override fun run() {
TODO("Not yet implemented")
}

View File

@@ -17,6 +17,9 @@ import java.time.LocalDateTime
)
class RunCommand : Runnable {
@CommandLine.Mixin
lateinit var helpOptions: HelpOptions
@CommandLine.Option(
names = ["-d", "--background"],
descriptionKey = "cli.run.option.background.description",

View File

@@ -12,6 +12,9 @@ import work.slhaf.partner.ctl.support.CommandInterrupted
)
class ShutdownCommand : Runnable {
@CommandLine.Mixin
lateinit var helpOptions: HelpOptions
@CommandLine.Option(
names = ["--timeout"],
descriptionKey = "cli.shutdown.option.timeout.description"