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 {
|
class ChatCommand : Runnable {
|
||||||
|
|
||||||
|
@CommandLine.Mixin
|
||||||
|
lateinit var helpOptions: HelpOptions
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
val terminal = createTerminal()
|
val terminal = createTerminal()
|
||||||
val reader = LineReaderBuilder.builder()
|
val reader = LineReaderBuilder.builder()
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import picocli.CommandLine
|
|||||||
description = [$$"${bundle:cli.config.description}"],
|
description = [$$"${bundle:cli.config.description}"],
|
||||||
)
|
)
|
||||||
class ConfigCommand : Runnable{
|
class ConfigCommand : Runnable{
|
||||||
|
|
||||||
|
@CommandLine.Mixin
|
||||||
|
lateinit var helpOptions: HelpOptions
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
TODO("Not yet implemented")
|
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 {
|
class InitCommand : Runnable {
|
||||||
|
|
||||||
|
@CommandLine.Mixin
|
||||||
|
lateinit var helpOptions: HelpOptions
|
||||||
|
|
||||||
lateinit var home: Path
|
lateinit var home: Path
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ import java.nio.file.Path
|
|||||||
)
|
)
|
||||||
class LogCommand : Runnable {
|
class LogCommand : Runnable {
|
||||||
|
|
||||||
|
@CommandLine.Mixin
|
||||||
|
lateinit var helpOptions: HelpOptions
|
||||||
|
|
||||||
@CommandLine.Option(
|
@CommandLine.Option(
|
||||||
names = ["--tail"],
|
names = ["--tail"],
|
||||||
descriptionKey = "cli.log.option.tail.description",
|
descriptionKey = "cli.log.option.tail.description",
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import picocli.CommandLine
|
|||||||
description = [$$"${bundle:cli.module.description}"],
|
description = [$$"${bundle:cli.module.description}"],
|
||||||
)
|
)
|
||||||
class ModuleCommand : Runnable{
|
class ModuleCommand : Runnable{
|
||||||
|
|
||||||
|
@CommandLine.Mixin
|
||||||
|
lateinit var helpOptions: HelpOptions
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ import java.time.LocalDateTime
|
|||||||
)
|
)
|
||||||
class RunCommand : Runnable {
|
class RunCommand : Runnable {
|
||||||
|
|
||||||
|
@CommandLine.Mixin
|
||||||
|
lateinit var helpOptions: HelpOptions
|
||||||
|
|
||||||
@CommandLine.Option(
|
@CommandLine.Option(
|
||||||
names = ["-d", "--background"],
|
names = ["-d", "--background"],
|
||||||
descriptionKey = "cli.run.option.background.description",
|
descriptionKey = "cli.run.option.background.description",
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ import work.slhaf.partner.ctl.support.CommandInterrupted
|
|||||||
)
|
)
|
||||||
class ShutdownCommand : Runnable {
|
class ShutdownCommand : Runnable {
|
||||||
|
|
||||||
|
@CommandLine.Mixin
|
||||||
|
lateinit var helpOptions: HelpOptions
|
||||||
|
|
||||||
@CommandLine.Option(
|
@CommandLine.Option(
|
||||||
names = ["--timeout"],
|
names = ["--timeout"],
|
||||||
descriptionKey = "cli.shutdown.option.timeout.description"
|
descriptionKey = "cli.shutdown.option.timeout.description"
|
||||||
|
|||||||
Reference in New Issue
Block a user