mirror of
https://github.com/corda/corda.git
synced 2024-12-20 21:43:14 +00:00
ENT-3001: Make subCommands
lazy val (#4668)
This is to prevent initialising it multiple times. Please see linked Jira to understand how this can cause harm.
This commit is contained in:
parent
cfa06853c0
commit
5744614886
@ -84,7 +84,7 @@ fun CordaCliWrapper.start(args: Array<String>) {
|
|||||||
exitProcess(ExitCodes.SUCCESS)
|
exitProcess(ExitCodes.SUCCESS)
|
||||||
} catch (e: ExecutionException) {
|
} catch (e: ExecutionException) {
|
||||||
val throwable = e.cause ?: e
|
val throwable = e.cause ?: e
|
||||||
if (this.verbose || this.subCommands().any { it.verbose }) {
|
if (this.verbose || this.subCommands.any { it.verbose }) {
|
||||||
throwable.printStackTrace()
|
throwable.printStackTrace()
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ abstract class CordaCliWrapper(alias: String, description: String) : CliWrapperB
|
|||||||
registerConverter(Path::class.java) { Paths.get(it).toAbsolutePath().normalize() }
|
registerConverter(Path::class.java) { Paths.get(it).toAbsolutePath().normalize() }
|
||||||
commandSpec.name(alias)
|
commandSpec.name(alias)
|
||||||
commandSpec.usageMessage().description(description)
|
commandSpec.usageMessage().description(description)
|
||||||
subCommands().forEach {
|
subCommands.forEach {
|
||||||
val subCommand = CommandLine(it)
|
val subCommand = CommandLine(it)
|
||||||
it.args = args
|
it.args = args
|
||||||
subCommand.commandSpec.usageMessage().description(it.description)
|
subCommand.commandSpec.usageMessage().description(it.description)
|
||||||
@ -173,8 +173,8 @@ abstract class CordaCliWrapper(alias: String, description: String) : CliWrapperB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun subCommands(): Set<CliWrapperBase> {
|
val subCommands: Set<CliWrapperBase> by lazy {
|
||||||
return additionalSubCommands() + installShellExtensionsParser
|
additionalSubCommands() + installShellExtensionsParser
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun call(): Int {
|
override fun call(): Int {
|
||||||
|
@ -79,7 +79,7 @@ private class ShellExtensionsGenerator(val parent: CordaCliWrapper) {
|
|||||||
val autoCompleteFile = getAutoCompleteFileLocation(alias)
|
val autoCompleteFile = getAutoCompleteFileLocation(alias)
|
||||||
autoCompleteFile.parent.createDirectories()
|
autoCompleteFile.parent.createDirectories()
|
||||||
val hierarchy = CommandLine(parent)
|
val hierarchy = CommandLine(parent)
|
||||||
parent.subCommands().forEach { hierarchy.addSubcommand(it.alias, it)}
|
parent.subCommands.forEach { hierarchy.addSubcommand(it.alias, it)}
|
||||||
|
|
||||||
val builder = StringBuilder(picocli.AutoComplete.bash(alias, hierarchy))
|
val builder = StringBuilder(picocli.AutoComplete.bash(alias, hierarchy))
|
||||||
builder.append(jarVersion(alias))
|
builder.append(jarVersion(alias))
|
||||||
|
Loading…
Reference in New Issue
Block a user