| 1 | = !RefactorErl CLI = |
| 2 | |
| 3 | This page introduces the Command Line Interface (CLI) of !RefactorErl. |
| 4 | |
| 5 | We provide the user with an [ErlangShellInterface Erlang shell interface], which proves to be pretty useful in most of the cases. However, we realised that sometimes one may need to access the tool from outside the Erlang shell. The proposed CLI provides a lightweight interface that can remotely execute Erlang commands in !RefactorErl. More precisely, it invokes Erlang functions that are specified by command line arguments. The method is based on [http://www.erlang.org/doc/man/escript.html Erlang Escript]. |
| 6 | |
| 7 | We note that the current version of CLI is a prototype, only discovering opportunities and usefulness of this kind of interface. Notice that the CLI is applicable directly by hand as well as indirectly by code editors. Latter makes !RefactorErl callable from editors that do not support Erlang. |
| 8 | |
| 9 | == Installation == |
| 10 | |
| 11 | If you have successfully downloaded and compiled !RefactorErl, you have nothing else to install. |
| 12 | |
| 13 | Before the first usage, you should redefine two functions defined in the !RefactorErl CLI: |
| 14 | |
| 15 | * referlpath() defines the directory path to the tool (''.'' by default) |
| 16 | * referlnode() defines the node name of the tool (''refactorerl@localhost'' by default) |
| 17 | |
| 18 | Also, you should make the ''!RefactorErl'' EScript executable. You may use a command like |
| 19 | |
| 20 | {{{ |
| 21 | chmod +x RefactorErl |
| 22 | }}} |
| 23 | |
| 24 | == Usage == |
| 25 | |
| 26 | Using the CLI is pretty straightforward. You can simply pass the following data to the script as command line arguments: |
| 27 | |
| 28 | * The name of the module the invoked function is located in |
| 29 | * The name of the invoked function |
| 30 | * The function arguments |
| 31 | |
| 32 | For example: |
| 33 | {{{ |
| 34 | /path/to/refactorerl/bin/RefactorErl mod fun arg1 arg2 "arg3" |
| 35 | }}} |
| 36 | |
| 37 | will invoke ''mod:fun(arg1, arg2, arg3)'' inside !RefactorErl. |
| 38 | |
| 39 | Note that Erlang terms written with spaces should be enclosed by double quote marks. |
| 40 | |
| 41 | === Handling the !RefactorErl server === |
| 42 | |
| 43 | First of all, if the !RefactorErl server is not running, you should start it up to be able to communicate with. Type |
| 44 | {{{ |
| 45 | RefactorErl start |
| 46 | }}} |
| 47 | |
| 48 | to start up. This command starts an instance of the tool at the previously given node. If the server is already running, you get a message of it. |
| 49 | |
| 50 | Also, you can stop the previously started !RefactorErl instance. If the server was not running, you will be informed. |
| 51 | |
| 52 | {{{ |
| 53 | RefactorErl stop |
| 54 | }}} |
| 55 | |
| 56 | == Use cases == |
| 57 | |
| 58 | Resetting the database: |
| 59 | {{{ |
| 60 | RefactorErl reset |
| 61 | RefactorErl ri reset |
| 62 | }}} |
| 63 | |
| 64 | Adding files: |
| 65 | {{{ |
| 66 | RefactorErl ri add "/path/to/module.erl" |
| 67 | }}} |
| 68 | |
| 69 | Listing database contents: |
| 70 | {{{ |
| 71 | RefactorErl ri ls |
| 72 | }}} |
| 73 | |
| 74 | Running the query ''mods.funs'' |
| 75 | {{{ |
| 76 | RefactorErl ri q "mods.funs" |
| 77 | }}} |
| 78 | |
| 79 | Renaming function ''mod:f/1'' to ''g'': |
| 80 | {{{ |
| 81 | RefactorErl ri renfun mod "{f, 1}" g |
| 82 | }}} |