ENT-4119: Make welcome message more accurate (#5596)

[ENT-4119] Make welcome message more accurate
This commit is contained in:
Jonathan Locke 2019-10-18 08:52:16 +01:00 committed by GitHub
commit 7d90e305ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 9 deletions

View File

@ -138,7 +138,7 @@ object InteractiveShell {
ExternalResolver.INSTANCE.addCommand("hashLookup", "Checks if a transaction with matching Id hash exists.", HashLookupShellCommand::class.java) ExternalResolver.INSTANCE.addCommand("hashLookup", "Checks if a transaction with matching Id hash exists.", HashLookupShellCommand::class.java)
ExternalResolver.INSTANCE.addCommand("attachments", "Commands to extract information about attachments stored within the node", AttachmentShellCommand::class.java) ExternalResolver.INSTANCE.addCommand("attachments", "Commands to extract information about attachments stored within the node", AttachmentShellCommand::class.java)
ExternalResolver.INSTANCE.addCommand("checkpoints", "Commands to extract information about checkpoints stored within the node", CheckpointShellCommand::class.java) ExternalResolver.INSTANCE.addCommand("checkpoints", "Commands to extract information about checkpoints stored within the node", CheckpointShellCommand::class.java)
shell = ShellLifecycle(configuration.commandsDirectory).start(config, configuration.user, configuration.password) shell = ShellLifecycle(configuration.commandsDirectory).start(config, configuration.user, configuration.password, runSshDaemon)
} }
fun runLocalShell(onExit: () -> Unit = {}) { fun runLocalShell(onExit: () -> Unit = {}) {
@ -166,7 +166,7 @@ object InteractiveShell {
} }
class ShellLifecycle(private val shellCommands: Path) : PluginLifeCycle() { class ShellLifecycle(private val shellCommands: Path) : PluginLifeCycle() {
fun start(config: Properties, localUserName: String = "", localUserPassword: String = ""): Shell { fun start(config: Properties, localUserName: String = "", localUserPassword: String = "", runSshDaemon: Boolean): Shell {
val classLoader = this.javaClass.classLoader val classLoader = this.javaClass.classLoader
val classpathDriver = ClassPathMountFactory(classLoader) val classpathDriver = ClassPathMountFactory(classLoader)
val fileDriver = FileMountFactory(Utils.getCurrentDirectory()) val fileDriver = FileMountFactory(Utils.getCurrentDirectory())
@ -192,7 +192,8 @@ object InteractiveShell {
return super.getPlugins().filterNot { it is JavaLanguage } + CordaAuthenticationPlugin(rpcOps) return super.getPlugins().filterNot { it is JavaLanguage } + CordaAuthenticationPlugin(rpcOps)
} }
} }
val attributes = emptyMap<String, Any>() val attributes = mutableMapOf<String, Any>()
attributes["crash.localShell"] = runSshDaemon
val context = PluginContext(discovery, attributes, commandsFS, confFS, classLoader) val context = PluginContext(discovery, attributes, commandsFS, confFS, classLoader)
context.refresh() context.refresh()
this.config = config this.config = config

View File

@ -3,12 +3,23 @@ package net.corda.tools.shell.base
// Note that this file MUST be in a sub-directory called "base" relative to the path // Note that this file MUST be in a sub-directory called "base" relative to the path
// given in the configuration code in InteractiveShell. // given in the configuration code in InteractiveShell.
welcome = """ welcome = { ->
if (crash.context.attributes["crash.localShell"] == true) {
"""
Welcome to the Corda interactive shell. Welcome to the Corda interactive shell.
Useful commands include 'help' to see what is available, and 'bye' to shut down the node. Useful commands include 'help' to see what is available, and 'bye' to exit the shell.
""" """.stripIndent()
} else {
"""
Welcome to the Corda interactive shell.
Useful commands include 'help' to see what is available, and 'bye' to shut down the node.
""".stripIndent()
}
}
prompt = { -> prompt = { ->
return "${new Date()}>>> " return "${new Date()}>>> "