Print the help message from subcommand
- Dominant language
- Kotlin
- Stars
- 951
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
The makeUsage command is `private` it should be `protected` so that sub classes can call it.
My usecase is that I have a subcommand that itself has subcommands, and if executed without a subcommand I want it to print the help message, e.g. `cli sc` prints help `cli sc ssc` does something.
My workaround is this.
```
import kotlinx.cli.*
import kotlin.reflect.full.*
class NewSubCommand: Subcommand("sc", "sc") {
override fun execute() {
// Print Help
ArgParser::class.declaredFunctions.find { it.name == "makeUsage" }?.let {
println(it.call(tiz))
}
}
}
```
Another workaround might be to throw an error with:
```
override fun execute() {
throw ParsingException("Needs Sub command")
}
```
but I think this is also not a great workaround.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating ArgParser.makeUsage and the Subcommand execution path described in the issue. Check how a subcommand with nested subcommands behaves when invoked without a child command, then make the usage method callable by subclasses and verify that `cli sc` prints help while `cli sc ssc` still executes the nested command.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100