Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Karaf Session object inside OSGiConsole #4635

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jimtng
Copy link
Contributor

@jimtng jimtng commented Mar 9, 2025

This PR provides Karaf's Session object through OSGiConsole object that's provided to ConsoleCommandExtensions.

The Karaf Session enables ConsoleCommandExtensions to prompt for user input. The simplest usage is provided through a convenience method OSGiConsole.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.

The Karaf `Session` enables ConsoleCommandExtensions to prompt for user input.

The simplest usage is provided through a convenience method `OSGiConsole.getSession().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.

Signed-off-by: Jimmy Tanagra <[email protected]>
@jimtng jimtng requested a review from a team as a code owner March 9, 2025 03:35
jimtng added 2 commits March 10, 2025 19:55
Signed-off-by: Jimmy Tanagra <[email protected]>
Signed-off-by: Jimmy Tanagra <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant