mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
feat(partnerctl): add shared help option mixin across commands
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -27,6 +27,9 @@ import java.nio.file.Paths
|
||||
)
|
||||
class InitCommand : Runnable {
|
||||
|
||||
@CommandLine.Mixin
|
||||
lateinit var helpOptions: HelpOptions
|
||||
|
||||
lateinit var home: Path
|
||||
|
||||
/**
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user