Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/kotlin/com/xenomachina/argparser/ArgParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ class ArgParser(
if (helpFormatter != null) {
option<Unit>("-h", "--help",
errorName = "HELP", // This should never be used, but we need to say something
help = "show this help message and exit") {
help = helpFormatter.helpMessage) { //now this message is customizable
throw ShowHelpException(helpFormatter, delegates.toList())
}.default(Unit).registerRoot()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class DefaultHelpFormatter(
val indent = " "
val indentWidth = indent.codePointWidth()

override value helpMessage = "show this help message and exit"

override fun format(
programName: String?,
columns: Int,
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/com/xenomachina/argparser/HelpFormatter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ package com.xenomachina.argparser
* Formats help for an [ArgParser].
*/
interface HelpFormatter {

/**
* The help message added automatically with the options -h, --help
*/
val helpMessage: String
/**
* Formats a help message.
*
Expand Down