-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[jrubyscripting] Add JRuby REPL and other utilities inside karaf console #18374
base: main
Are you sure you want to change the base?
Conversation
6b2209c
to
2eb74b6
Compare
2eb74b6
to
547ac87
Compare
Signed-off-by: Jimmy Tanagra <[email protected]>
Signed-off-by: Jimmy Tanagra <[email protected]>
547ac87
to
81d7750
Compare
...c/main/java/org/openhab/automation/jrubyscripting/internal/JRubyConsoleCommandExtension.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/openhab/automation/jrubyscripting/internal/JRubyConsoleCommandExtension.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/openhab/automation/jrubyscripting/internal/JRubyConsoleCommandExtension.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/openhab/automation/jrubyscripting/internal/JRubyConsoleCommandExtension.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/openhab/automation/jrubyscripting/internal/JRubyConsoleCommandExtension.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/openhab/automation/jrubyscripting/internal/JRubyConsoleCommandExtension.java
Outdated
Show resolved
Hide resolved
Updated to use repl code from the helper library openhab/openhab-jruby#405 |
Signed-off-by: Jimmy Tanagra <[email protected]>
6d8eca4
to
9f01a5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to run mvn i18n-generate-default-translations
, no?
<description><![CDATA[The script file to be required by the <tt>jrubyscripting console</tt> | ||
console command.]]></description> | ||
<default>openhab/console/irb</default> | ||
<advanced>true</advanced> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the whole group is already advanced, does the individual item need other be advanced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried removing the advanced tag from the individual items, whilst keeping it in the group. This would make them show up even when the "advanced" checkbox isn't selected. It seems like a "bug" somewhere, but for the time being we'll have to stick with how it goes.
} | ||
|
||
executeWithFullJRuby(console, engine -> { | ||
engine.getContext().setAttribute("$console", console, ScriptContext.ENGINE_SCOPE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need console? or would session be enough? (really, all I'm using right now is terminal - which you get from session). then you don't event need the JRubyConsole. in the one or two places that need session, just pass it through from execute().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it to just $terminal. However, we still need JRubyConsole
because the OSGiConsole class from core is in an internal package. We still want to have a console
object to keep a resemblance to the standard ConsoleCommandExtension in case we need to refactor this back if openhab/openhab-core#4635 is accepted.
e8d4c09
to
04d2f9f
Compare
…ties Signed-off-by: Jimmy Tanagra <[email protected]>
04d2f9f
to
0618843
Compare
Signed-off-by: Jimmy Tanagra <[email protected]>
Signed-off-by: Jimmy Tanagra <[email protected]>
a4ecdce
to
c94593c
Compare
Signed-off-by: Jimmy Tanagra <[email protected]>
c94593c
to
2411ea4
Compare
Add Karaf console utilities for JRuby, including a REPL environment that runs inside the same script engine as normal rules.
The REPL shell supports:
This next screenshot shows it running in my production instance:

An alternative implementation can be done should openhab/openhab-core#4635 be merged. For the time being, this PR stands alone and will work without the linked core PR. When the core PR is merged and this is refactored, we can remove the dependency to karaf in pom.xml.
If the core PR gets merged, I can refactor this later if necessary. I don't want the core PR be a blocker for this PR though.