Provide Karaf Session object inside OSGiConsole #4635
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR provides Karaf's Session object through OSGiConsole object that's provided to
ConsoleCommandExtension
s.The Karaf
Session
enables ConsoleCommandExtensions to prompt for user input. The simplest usage is provided through a convenience methodOSGiConsole.readLine()
.A more advanced usage is also possible by constructing a custom org.jline.reader.LineReader object which requires the Terminal from console.getSession().getTerminal(). This is useful for more complex input scenarios, such as when you need to have sub-shell history, custom completion, etc.
This PR will enable the creation of a JRuby REPL inside the Karaf console. This REPL will run inside the same engine / environment as a normal JRuby rule, so it will have access to runtime Items, Things, events, etc, just like a normal openHAB script.