mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +08:00
feat(partnerctl): i18n-ize command and option descriptions via message bundles
This commit is contained in:
@@ -9,6 +9,8 @@ import kotlin.system.exitProcess
|
|||||||
|
|
||||||
@CommandLine.Command(
|
@CommandLine.Command(
|
||||||
name = "partnerctl",
|
name = "partnerctl",
|
||||||
|
resourceBundle = "i18n.messages",
|
||||||
|
description = [$$"${bundle:cli.partnerctl.description}"],
|
||||||
mixinStandardHelpOptions = true,
|
mixinStandardHelpOptions = true,
|
||||||
version = ["partnerctl 0.1.0"],
|
version = ["partnerctl 0.1.0"],
|
||||||
subcommands = [
|
subcommands = [
|
||||||
@@ -20,8 +22,7 @@ import kotlin.system.exitProcess
|
|||||||
ConfigCommand::class,
|
ConfigCommand::class,
|
||||||
ModuleCommand::class,
|
ModuleCommand::class,
|
||||||
AutoComplete.GenerateCompletion::class
|
AutoComplete.GenerateCompletion::class
|
||||||
],
|
]
|
||||||
description = ["Partner command line tool."]
|
|
||||||
)
|
)
|
||||||
class PartnerCtl : Runnable {
|
class PartnerCtl : Runnable {
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import picocli.CommandLine
|
|||||||
|
|
||||||
@CommandLine.Command(
|
@CommandLine.Command(
|
||||||
name = "chat",
|
name = "chat",
|
||||||
description = ["Start an interactive chat demo."]
|
resourceBundle = "i18n.messages",
|
||||||
|
description = [$$"${bundle:cli.chat.description}"],
|
||||||
)
|
)
|
||||||
class ChatCommand : Runnable {
|
class ChatCommand : Runnable {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ package work.slhaf.partner.ctl.commands
|
|||||||
|
|
||||||
import picocli.CommandLine
|
import picocli.CommandLine
|
||||||
|
|
||||||
@CommandLine.Command(name = "config")
|
@CommandLine.Command(
|
||||||
|
name = "config",
|
||||||
|
resourceBundle = "i18n.messages",
|
||||||
|
description = [$$"${bundle:cli.config.description}"],
|
||||||
|
)
|
||||||
class ConfigCommand : Runnable{
|
class ConfigCommand : Runnable{
|
||||||
override fun run() {
|
override fun run() {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ import java.nio.file.Files
|
|||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
@CommandLine.Command(name = "init", description = ["Initialize partner agent."])
|
@CommandLine.Command(
|
||||||
|
name = "init",
|
||||||
|
resourceBundle = "i18n.messages",
|
||||||
|
description = [$$"${bundle:cli.init.description}"],
|
||||||
|
)
|
||||||
class InitCommand : Runnable {
|
class InitCommand : Runnable {
|
||||||
|
|
||||||
lateinit var home: Path
|
lateinit var home: Path
|
||||||
|
|||||||
@@ -7,13 +7,23 @@ import work.slhaf.partner.ctl.i18n.I18n.text
|
|||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
@CommandLine.Command(name = "log", description = ["Show Partner logs."])
|
@CommandLine.Command(
|
||||||
|
name = "log",
|
||||||
|
resourceBundle = "i18n.messages",
|
||||||
|
description = [$$"${bundle:cli.log.description}"],
|
||||||
|
)
|
||||||
class LogCommand : Runnable {
|
class LogCommand : Runnable {
|
||||||
|
|
||||||
@CommandLine.Option(names = ["--tail"], description = ["Number of log lines to show before exiting or following."])
|
@CommandLine.Option(
|
||||||
|
names = ["--tail"],
|
||||||
|
descriptionKey = "cli.log.option.tail.description",
|
||||||
|
)
|
||||||
var tailLines: Int = 200
|
var tailLines: Int = 200
|
||||||
|
|
||||||
@CommandLine.Option(names = ["-f", "--follow"], description = ["Follow appended log output."])
|
@CommandLine.Option(
|
||||||
|
names = ["-f", "--follow"],
|
||||||
|
descriptionKey = "cli.log.option.follow.description",
|
||||||
|
)
|
||||||
var follow: Boolean = false
|
var follow: Boolean = false
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ package work.slhaf.partner.ctl.commands
|
|||||||
|
|
||||||
import picocli.CommandLine
|
import picocli.CommandLine
|
||||||
|
|
||||||
@CommandLine.Command(name = "module")
|
@CommandLine.Command(
|
||||||
|
name = "module",
|
||||||
|
resourceBundle = "i18n.messages",
|
||||||
|
description = [$$"${bundle:cli.module.description}"],
|
||||||
|
)
|
||||||
class ModuleCommand : Runnable{
|
class ModuleCommand : Runnable{
|
||||||
override fun run() {
|
override fun run() {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
|
|||||||
@@ -10,10 +10,17 @@ import java.nio.file.Path
|
|||||||
import java.nio.file.StandardOpenOption
|
import java.nio.file.StandardOpenOption
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
@CommandLine.Command(name = "run", description = ["Start Partner agent."])
|
@CommandLine.Command(
|
||||||
|
name = "run",
|
||||||
|
resourceBundle = "i18n.messages",
|
||||||
|
description = [$$"${bundle:cli.run.description}"],
|
||||||
|
)
|
||||||
class RunCommand : Runnable {
|
class RunCommand : Runnable {
|
||||||
|
|
||||||
@CommandLine.Option(names = ["-d", "--background"], description = ["Run Partner in background."])
|
@CommandLine.Option(
|
||||||
|
names = ["-d", "--background"],
|
||||||
|
descriptionKey = "cli.run.option.background.description",
|
||||||
|
)
|
||||||
var background: Boolean = false
|
var background: Boolean = false
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
|||||||
@@ -5,18 +5,22 @@ import work.slhaf.partner.ctl.commands.control.*
|
|||||||
import work.slhaf.partner.ctl.i18n.I18n
|
import work.slhaf.partner.ctl.i18n.I18n
|
||||||
import work.slhaf.partner.ctl.support.CommandInterrupted
|
import work.slhaf.partner.ctl.support.CommandInterrupted
|
||||||
|
|
||||||
@CommandLine.Command(name = "shutdown", description = ["Shutdown Partner agent."])
|
@CommandLine.Command(
|
||||||
|
name = "shutdown",
|
||||||
|
resourceBundle = "i18n.messages",
|
||||||
|
description = [$$"${bundle:cli.shutdown.description}"],
|
||||||
|
)
|
||||||
class ShutdownCommand : Runnable {
|
class ShutdownCommand : Runnable {
|
||||||
|
|
||||||
@CommandLine.Option(
|
@CommandLine.Option(
|
||||||
names = ["--timeout"],
|
names = ["--timeout"],
|
||||||
description = ["Seconds to wait after graceful termination before failing or forcing shutdown."]
|
descriptionKey = "cli.shutdown.option.timeout.description"
|
||||||
)
|
)
|
||||||
var timeoutSeconds: Long = 10
|
var timeoutSeconds: Long = 10
|
||||||
|
|
||||||
@CommandLine.Option(
|
@CommandLine.Option(
|
||||||
names = ["-f", "--force"],
|
names = ["-f", "--force"],
|
||||||
description = ["Forcefully kill matching Partner process if it does not exit before timeout."]
|
descriptionKey = "cli.shutdown.option.force.description"
|
||||||
)
|
)
|
||||||
var force: Boolean = false
|
var force: Boolean = false
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
cli.partnerctl.description=Partner command line tool.
|
||||||
|
cli.init.description=Initialize Partner agent.
|
||||||
|
cli.run.description=Start Partner agent.
|
||||||
|
cli.run.option.background.description=Run Partner in background.
|
||||||
|
cli.shutdown.description=Shutdown Partner agent.
|
||||||
|
cli.shutdown.option.timeout.description=Seconds to wait after graceful termination before failing or forcing shutdown.
|
||||||
|
cli.shutdown.option.force.description=Forcefully kill matching Partner process if it does not exit before timeout.
|
||||||
|
cli.log.description=Show Partner logs.
|
||||||
|
cli.log.option.tail.description=Number of log lines to show before exiting or following.
|
||||||
|
cli.log.option.follow.description=Follow appended log output.
|
||||||
|
cli.chat.description=Start an interactive chat demo.
|
||||||
|
cli.config.description=Manage Partner configuration.
|
||||||
|
cli.module.description=Manage Partner modules.
|
||||||
|
|
||||||
init.home.section=Initialize Partner Home
|
init.home.section=Initialize Partner Home
|
||||||
init.home.label=Partner Home
|
init.home.label=Partner Home
|
||||||
init.home.success=Partner Home initialized at {0}
|
init.home.success=Partner Home initialized at {0}
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
cli.partnerctl.description=Partner 命令行工具。
|
||||||
|
cli.init.description=初始化 Partner agent。
|
||||||
|
cli.run.description=启动 Partner agent。
|
||||||
|
cli.run.option.background.description=后台运行 Partner。
|
||||||
|
cli.shutdown.description=停止 Partner agent。
|
||||||
|
cli.shutdown.option.timeout.description=优雅停止后等待的秒数,超时后失败或强制停止。
|
||||||
|
cli.shutdown.option.force.description=如果匹配的 Partner 进程没有在超时前退出,则强制结束进程。
|
||||||
|
cli.log.description=查看 Partner 日志。
|
||||||
|
cli.log.option.tail.description=退出或 follow 前显示的日志行数。
|
||||||
|
cli.log.option.follow.description=持续跟随新增日志输出。
|
||||||
|
cli.chat.description=启动交互式聊天 demo。
|
||||||
|
cli.config.description=管理 Partner 配置。
|
||||||
|
cli.module.description=管理 Partner 模块。
|
||||||
|
|
||||||
init.home.section=初始化 Partner Home
|
init.home.section=初始化 Partner Home
|
||||||
init.home.label=Partner Home
|
init.home.label=Partner Home
|
||||||
init.home.success=Partner Home 已初始化:{0}
|
init.home.success=Partner Home 已初始化:{0}
|
||||||
|
|||||||
Reference in New Issue
Block a user