Add support for rendering help info for input and output

This commit is contained in:
Paul Schaub 2024-09-18 15:50:17 +02:00
parent ddf4ba19f9
commit a607013cfb
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
4 changed files with 120 additions and 6 deletions

View file

@ -81,8 +81,8 @@ class SopCLI {
// Re-set bundle with updated locale
cliMsg = ResourceBundle.getBundle("msg_sop")
return CommandLine(SopCLI::class.java)
.apply {
val cmd =
CommandLine(SopCLI::class.java).apply {
// explicitly set help command resource bundle
subcommands["help"]?.setResourceBundle(ResourceBundle.getBundle("msg_help"))
// Hide generate-completion command
@ -94,7 +94,15 @@ class SopCLI {
exitCodeExceptionMapper = SOPExceptionExitCodeMapper()
isCaseInsensitiveEnumValuesAllowed = true
}
.execute(*args)
// render Input/Output sections in help command
cmd.subcommands.values
.filter {
(it.getCommand() as Any) is AbstractSopCmd
} // Only for AbstractSopCmd objects
.forEach { (it.getCommand() as AbstractSopCmd).installIORenderer(it) }
return cmd.execute(*args)
}
}