Skip to content

Commit dbf5c99

Browse files
author
LepilkinaElena
authored
Fix printing help message for subcommands (#44)
1 parent f917f17 commit dbf5c99

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/commonMain/src/ArgParser.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ open class ArgParser(
143143
/**
144144
* Used prefix form for full option form.
145145
*/
146-
private val optionFullFormPrefix = if (prefixStyle == OptionPrefixStyle.JVM) "-" else "--"
146+
protected val optionFullFormPrefix = if (prefixStyle == OptionPrefixStyle.JVM) "-" else "--"
147147

148148
/**
149149
* Used prefix form for short option form.
150150
*/
151-
private val optionShortFromPrefix = "-"
151+
protected val optionShortFromPrefix = "-"
152152

153153
/**
154154
* Name with all commands that should be executed.
@@ -436,7 +436,9 @@ open class ArgParser(
436436
internal fun saveOptionWithoutParameter(argValue: ParsingValue<*, *>) {
437437
// Boolean flags.
438438
if (argValue.descriptor.fullName == "help") {
439-
usedSubcommand?.saveOptionWithoutParameter(argValue)
439+
usedSubcommand?.let {
440+
it.parse(listOf("${it.optionFullFormPrefix}${argValue.descriptor.fullName}"))
441+
}
440442
println(makeUsage())
441443
exitProcess(0)
442444
}

0 commit comments

Comments
 (0)