Version 17 by tobi on 16. December 2009, 00:15
| 12 | Thanks to Robert and Hannes for their help; it wouldn't would not be even alpha without them. |
| 14 | <em>Update:</em> I added the file <code>patch-for-emacs-integration.diff</code> which Massimiliano sent to me; he "added “added a few bits, namely set/get/push/popenv and the multiline input mode, needed for Emacs integration." ” Maybe this helps other Emacs users, too. |
| 16 | Here's Here is what you can do with it:HopRepl: |
| 24 | To be sure that the HopRepl code is really compiled into the application a Helma restart won't will not hurt. |
| 26 | Now you can start the HopRepl server by navigating to the "repl" “repl” action in your browser. In my case the location is http://localhost:8080/manage/repl |
| 28 | There you will see one simple line saying "HopRepl “HopRepl server (stopped)" (stopped)” followed by two links "Start" “Start” and "Restart"“Restart”. |
| 30 | Click on the "Start" “Start” link and your HopRepl should be started. Simultaneously, the link will change to "Stop" “Stop” and the port number will be displayed in brackets. |
| 36 | Let's Let us check if you can connect from the command line shell to the HopRepl server by entering |
| 49 | After the prompt you can enter any JavaScript statement you like. It will be (R)ead, (E)valuated and the result will be (P)rinted in your terminal. Finally, the (L)oop starts again with your next input. That's That is the generic principle behind Repl. |
| 90 | For convenience you don't do not have to always type in "this" “this” to access a property or a method. HopRepl provides all available properties of the current context as global variables: |
| 138 | Of course you can also call methods, not only enter their contextes. Here's Here is a more elaborated example of using HopRepl to stop an application: |
| 152 | Further manipulation is possible, too. Let's Let us change a HopObject's HopObject’s property: |
| 176 | Helma> repl.back(); repl.back() // Back to the application's application’s context |
| 182 | That's That is it so far. Maybe this first attempt will grow and if anyone is interested in picking up the pieces, please contact me via the helma-dev mailing list. |
| 189 | Inspired by Massimiliano Mirra's Mirra’s <a href="http://hyperstruct.net/projects/mozrepl">MozRepl</a> project. |
Version 16 by tobi on 16. December 2009, 00:05
| 4 | <small>Note: <small><em>Note:</em> Chris Langreiter was here years ago already when he published <a href="http://www.langreiter.com/space/HopShell">HopShell</a>, a REPL Repl written in Rebol.</small> |
| 6 | The four letters <a href="http://en.wikipedia.org/wiki/REPL">REPL</a> >Repl</a> actually are in fact used synonymously for a shell. |
| 28 | There you will see one simple line saying "HopREPL HopRepl server (stopped)" followed by two links "Start" and "Restart". |
| 44 | If everyhing goes well HopRepl should welcome you with a short message and the REPL Repl prompt: |
| 47 | REPL> Helma> |
| 49 | After the prompt you can enter any JavaScript statement you like. It will be (R)ead, (E)valuated and the result will be (P)rinted in your terminal. Finally, the (L)oop starts again with your next input. That's the generic principle behind REPLRepl. |
| 51 | REPL> Helma> new Date |
| 53 | REPL> Helma> Math |
| 55 | REPL> Helma> this |
| 60 | REPL> Helma> repl |
| 61 | HopREPL HopRepl server (port 1234) |
| 64 | REPL> Helma> repl.whereAmI() |
| 69 | REPL> Helma> repl.look() |
| 91 | REPL> Helma> res |
| 93 | REPL> Helma> session |
| 95 | REPL> Helma> skin_macro |
| 104 | REPL> Helma> repl.enter(root) |
| 106 | REPL> Helma> repl.look() |
| 115 | REPL> Helma> repl.enter(checkAppManager) |
| 122 | REPL> Helma> repl.back() |
| 127 | REPL> Helma> repl.home() |
| 132 | REPL> Helma> repl.quit() |
| 139 | REPL> Helma> repl.home() |
| 141 | REPL> Helma> repl.enter(root) |
| 143 | REPL> Helma> repl.enter(getApplication("test")) |
| 145 | REPL> Helma> isRunning() |
| 147 | REPL> Helma> stop() |
| 148 | REPL> Helma> isRunning() |
| 152 | REPL> Helma> repl.home() |
| 154 | REPL>> Helma>> repl.enter(root) |
| 156 | REPL> Helma> repl.enter(getApplication("antville")) |
| 158 | REPL> Helma> repl.enter(dataRoot) |
| 160 | REPL> Helma> repl.enter(creator) |
| 162 | REPL> Helma> repl.look() |
| 168 | REPL> Helma> email = "somebody@somewhere.com" |
| 173 | REPL> Helma> res.commit() |
| 174 | REPL> Helma> repl.back(); repl.back() // Back to the application's context |
| 175 | REPL> Helma> clearCache() |
| 176 | REPL> Helma> dataRoot.creator.email |
Version 15 by tobi on 15. December 2009, 23:59
| 42 | <small><em>Note:</em> To add command editing, history and completion features to the Repl you could prefix the above command with <a href="http://utopia.knoware.nl/~hlub/rlwrap/"><code>rlwrap</code></a> – which of course needs to be installed on your machine.</small> |
| 43 |
Version 14 by simono on 15. October 2009, 11:30
| 182 | Inspired by Massimiliano Mirra's <a href="http://hyperstruct.net/projects/mozrepl">MozRepl</a> project I quickly coded a similar tool, for now dubbed HopRepl. |
| 183 | |
| 187 | |
| 188 | Inspired by Massimiliano Mirra's <a href="http://hyperstruct.net/projects/mozrepl">MozRepl</a> project. |
Version 13 by zumbrunn on 15. October 2009, 11:25
| 2 | HopRepl actually is similar to <a href="https://dev.helma.org/trac/helma/browser/apps/helmaTools/trunk/Global/helma.shell.js">Helma Shell</a> with the tiny difference that it does not run in a browser window but in a terminal environment (aka command line). |
Version 12 by simono on 15. October 2009, 11:18
- Set useMarkdown to
| 2 | |
| 3 | Inspired by Massimiliano Mirra's <a href="http://hyperstruct.net/projects/mozrepl">MozRepl</a> project I quickly coded a similar tool, for now dubbed HopRepl. |
| 4 | |
| 182 | |
| 183 | Inspired by Massimiliano Mirra's <a href="http://hyperstruct.net/projects/mozrepl">MozRepl</a> project I quickly coded a similar tool, for now dubbed HopRepl. |
Version 11 by tobi on 15. October 2008, 15:31
- Changed tags to shell, introspection, Tobi, REPL
| 187 | * Eat <s>Eat those nasty java.lang.Nullpointer exceptions (could be something with entering Java class context)context)</s> Fixed by preventing HopRepl from entering scopes with undefined constructor property. |
Version 10 by tobi on 18. February 2008, 11:26
| 17 | <em>Update:</em> I added the file <code>patch-for-emacs-integration.diff</code> which Massimiliano sent to me; he "added a few bits, namely set/get/push/popenv and the multiline input mode, needed for EmacsEmacs integration." Maybe this helps other Emacs users, too. |
| 18 | integration." Maybe this helps other Emacs users, too. |
Version 9 by tobi on 18. February 2008, 11:25
| 17 | <em>Update:</em> I added the file <code>patch-for-emacs-integration.diff</code> which Massimiliano sent to me; he "added a few bits, namely set/get/push/popenv and the multiline input mode, needed for Emacs |
| 18 | integration." Maybe this helps other Emacs users, too. |
| 19 |
Version 8 by tobi on 19. January 2008, 12:53
| 172 | Please note that the e-mail address is not changed in the database, yet. To achieve this one could has to add a <code>res.commit()</code> at this point. After invalidating the application – which of course could can be done in HopRepl as well by invoking <code>app.clearCache()</code> – the new value will also be displayed when its property is requested:still persistent: |
| 178 | REPL> dataRoot.creator.email |
| 179 | somebody@somewhere.com |
Version 7 by tobi on 19. January 2008, 12:47
| 172 | Please note that the e-mail address is not changed in the database, yet. To achieve this one could add a <code>res.commit()</code> at this point. After invalidating the application – which of course could be done in HopRepl as well by invoking <code>app.clearCache()</code> – the new value will also be displayed when its property is requested.requested: |
| 173 | |
| 174 | REPL> res.commit() |
| 175 | REPL> repl.back(); repl.back() // Back to the application's context |
| 176 | [Application antville] |
| 177 | REPL> clearCache() |
Version 6 by tobi on 19. January 2008, 12:40
| 172 | Unfortunately, this version of HopRepl being absolutely in alpha stage cannot change Please note that the database value of properties. At least I currently did e-mail address is not succeed changed in doing sothe database, yet. I cannot even predict if To achieve this will one could add a <code>res.commit()</code> at this point. After invalidating the application – which of course could be possible done in that mannerHopRepl as well by invoking <code>app..clearCache()</code> – the new value will also be displayed when its property is requested. |
| 174 | However,That's it so far. maybe Maybe this first attempt will grow and if anyone is interested in picking up the pieces, please contact me via the helma-dev mailing list. |
| 179 | * Allow <s>Allow modifications of properties to trickle down to the databasedatabase</s> Works with <code>res.commit()</code> |
Version 5 by tobi on 17. January 2008, 16:27
| 169 | REPL> email = "somebody@somewhere.com" |
Version 4 by tobi on 17. January 2008, 16:21
| 1 | === Introduction |
| 2 | |
| 178 | * Allow modifications of properties to trickle down to the database |
Version 3 by tobi on 17. January 2008, 16:17
| 5 | <small>Note: Chris Langreiter was here years ago already when he published <a href="http://www.langreiter.com/space/HopShell">HopShell</a>., I don't know what happened to it right nowa REPL written in Rebol.</small> |
Version 2 by tobi on 17. January 2008, 16:15
- Changed tags to Tobi, REPL, shell, introspection
| 3 | HopRepl actually is similar to HopShell <a href="https://dev.helma.org/trac/helma/browser/apps/helmaTools/trunk/Global/helma.shell.js">Helma Shell</a> with the tiny difference that it does not run in a browser window but in a terminal environment (aka command line). |
| 5 | <small>Note: Chris Langreiter was here years ago already when he published <a href="http://www.langreiter.com/space/HopShell">HopShell</a>. I don't know what happened to it right now.</small> |
| 6 | |
| 16 | === Installation and setupAnd Setup |
| 18 | First, move the two files attached to this wiki as repl.zip and repl.jar into you your application directory. I recommend the manage application because it already provides some interesting objects to explore. |
| 171 | However, maybe this first attempt will grow and if anyone is interested in picking up the pieces, please contact me via the helma-dev mailing list. // *tobi* |
| 172 | |
| 173 | === To Do |
| 174 | |
| 175 | * Eat those nasty java.lang.Nullpointer exceptions (could be something with entering Java class context) |
| 176 | |
| 177 | // *tobi* |
Version 1 by tobi on 17. January 2008, 15:00
- Set tags to shell, introspection, Tobi, REPL
| 1 | Inspired by Massimiliano Mirra's <a href="http://hyperstruct.net/projects/mozrepl">MozRepl</a> project I quickly coded a similar tool, for now dubbed HopRepl. |
| 3 | HopRepl actually is similar to HopShell with the tiny difference that it does not run in a browser window but in a terminal environment (aka command line). |
| 4 | |
| 5 | The four letters <a href="http://en.wikipedia.org/wiki/REPL">REPL</a> actually are in fact used synonymously for a shell. |
| 6 | |
| 7 | Thus, you can enter simple commands to inspect and manipulate Helma space. And commands are of course JavaScript statements! |
| 8 | |
| 9 | This is an alpha version, ie. you will get excepctions, stuck and not always what you expected. |
| 10 | |
| 11 | Thanks to Robert and Hannes for their help; it wouldn't be even alpha without them. |
| 12 | |
| 13 | Here's what you can do with it: |
| 14 | |
| 15 | === Installation and setup |
| 16 | |
| 17 | First, move the two files attached to this wiki as repl.zip and repl.jar into you application directory. I recommend the manage application because it already provides some interesting objects to explore. |
| 18 | |
| 19 | <% this.attachments %> |
| 20 | |
| 21 | To be sure that the HopRepl code is really compiled into the application a Helma restart won't hurt. |
| 22 | |
| 23 | Now you can start the HopRepl server by navigating to the "repl" action in your browser. In my case the location is http://localhost:8080/manage/repl |
| 24 | |
| 25 | There you will see one simple line saying "HopREPL server (stopped)" followed by two links "Start" and "Restart". |
| 26 | |
| 27 | Click on the "Start" link and your HopRepl should be started. Simultaneously, the link will change to "Stop" and the port number will be displayed in brackets. |
| 28 | |
| 29 | (If not you might check if anything else is running behind that port on your computer already. Use the application property replPort to change the port number.) |
| 30 | |
| 31 | === Using HopRepl |
| 32 | |
| 33 | Let's check if you can connect from the command line shell to the HopRepl server by entering |
| 34 | |
| 35 | telnet localhost 1234 |
| 36 | |
| 37 | (Be sure to use the desired port number if you should have changed it in the previous step.) |
| 38 | |
| 39 | If everyhing goes well HopRepl should welcome you with a short message and the REPL prompt: |
| 40 | |
| 41 | Hello! This is HopRepl Alpha (c) 2008 Tobi Schäfer |
| 42 | REPL> |
| 43 | |
| 44 | After the prompt you can enter any JavaScript statement you like. It will be (R)ead, (E)valuated and the result will be (P)rinted in your terminal. Finally, the (L)oop starts again with your next input. That's the generic principle behind REPL. |
| 45 | |
| 46 | REPL> new Date |
| 47 | Thu Jan 17 2008 12:21:57 GMT+0100 (CET) |
| 48 | REPL> Math |
| 49 | [object Math] |
| 50 | REPL> this |
| 51 | [object GlobalObject] |
| 52 | |
| 53 | There is one special object added to the JavaScript as defined by Rhino and Helma. It is called repl and acts as a helper object providing methods to make navigating and exploring the namespace more convenient. |
| 54 | |
| 55 | REPL> repl |
| 56 | HopREPL server (port 1234) |
| 57 | |
| 58 | To get a clue where in Helma space you are right now you can use the whereAmI() method: |
| 59 | |
| 60 | REPL> repl.whereAmI() |
| 61 | [object GlobalObject] |
| 62 | |
| 63 | The look() method prints a list of all available properties and methods in the current context: |
| 64 | |
| 65 | REPL> repl.look() |
| 66 | this.Repl = [function] |
| 67 | this.Server = [function] |
| 68 | this.Thread = [function] |
| 69 | this.Xml = {class helma.scripting.rhino.extensions.XmlObject} |
| 70 | this.app = {class helma.framework.core.ApplicationBean} |
| 71 | this.appStat = [function] |
| 72 | this.checkAddress = [function] |
| 73 | this.checkAuth = [function] |
| 74 | this.createAddressFilter = [function] |
| 75 | ... |
| 76 | this.req = {class helma.framework.RequestBean} |
| 77 | this.res = {class helma.framework.ResponseBean} |
| 78 | this.root = {class helma.main.Server} |
| 79 | this.scheduler = [function] |
| 80 | this.session = {class helma.framework.core.SessionBean} |
| 81 | this.skin_macro = [function] |
| 82 | this.sortByName = [function] |
| 83 | this.sortProps = [function] |
| 84 | |
| 85 | For convenience you don't have to always type in "this" to access a property or a method. HopRepl provides all available properties of the current context as global variables: |
| 86 | |
| 87 | REPL> res |
| 88 | [Response] |
| 89 | REPL> session |
| 90 | [Anonymous Session] |
| 91 | REPL> skin_macro |
| 92 | function skin_macro(par) { |
| 93 | if (par && par.name) { |
| 94 | renderSkin(par.name); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | The enter() method changes the context to another object: |
| 99 | |
| 100 | REPL> repl.enter(root) |
| 101 | helma.main.Server@d03ed2 |
| 102 | REPL> repl.look() |
| 103 | this.application = undefined |
| 104 | this.applications = {class [Ljava.lang.Object;} |
| 105 | this.appsHome = {class java.io.File} |
| 106 | this.appsProperties = undefined |
| 107 | this.checkAppManager = [function] |
| 108 | this.class = {class java.lang.Class} |
| 109 | this.dbHome = {class java.io.File} |
| 110 | ... |
| 111 | REPL> repl.enter(checkAppManager) |
| 112 | function checkAppManager() {/* |
| 113 | void checkAppManager(int) |
| 114 | */} |
| 115 | |
| 116 | To get back to the previous context the back() method is at hand: |
| 117 | |
| 118 | REPL> repl.back() |
| 119 | helma.main.Server@d03ed2 |
| 120 | |
| 121 | And the home() method brings you even further back, straight up to the top-level context: |
| 122 | |
| 123 | REPL> repl.home() |
| 124 | [object GlobalObject] |
| 125 | |
| 126 | If you should have enough of tinkering with HopRepl the quit() method closes the connection to the server: |
| 127 | |
| 128 | REPL> repl.quit() |
| 129 | Connection closed by foreign host. |
| 130 | |
| 131 | === Getting Nifty |
| 132 | |
| 133 | Of course you can also call methods, not only enter their contextes. Here's a more elaborated example of using HopRepl to stop an application: |
| 134 | |
| 135 | REPL> repl.home() |
| 136 | [object GlobalObject] |
| 137 | REPL> repl.enter(root) |
| 138 | helma.main.Server@d03ed2 |
| 139 | REPL> repl.enter(getApplication("test")) |
| 140 | [Application test] |
| 141 | REPL> isRunning() |
| 142 | true |
| 143 | REPL> stop() |
| 144 | REPL> isRunning() |
| 145 | false |
| 146 | |
| 147 | Further manipulation is possible, too. Let's change a HopObject's property: |
| 148 | |
| 149 | REPL> repl.home() |
| 150 | [object GlobalObject] |
| 151 | REPL>> repl.enter(root) |
| 152 | helma.main.Server@d03ed2 |
| 153 | REPL> repl.enter(getApplication("antville")) |
| 154 | [Application antville] |
| 155 | REPL> repl.enter(dataRoot) |
| 156 | HopObject Site 14 |
| 157 | REPL> repl.enter(creator) |
| 158 | HopObject p3k |
| 159 | REPL> repl.look() |
| 160 | this.comments = [object] |
| 161 | this.created = [object] |
| 162 | this.email = nobody@nowhere.com |
| 163 | this.files = [object] |
| 164 | ... |
| 165 | REPL> email = somebody@somewhere.com |
| 166 | somebody@somewhere.com |
| 167 | |
| 168 | Unfortunately, this version of HopRepl being absolutely in alpha stage cannot change the database value of properties. At least I currently did not succeed in doing so. I cannot even predict if this will be possible in that manner...? |
| 169 | |
| 170 | However, maybe this first attempt will grow and if anyone is interested in picking up the pieces, please contact me via the helma-dev mailing list. // *tobi* |