= !RefactorErl CLI = This page introduces the Command Line Interface (CLI) of !RefactorErl. 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://en.wikipedia.org/wiki/Remote_procedure_call RPC] and [http://www.erlang.org/doc/man/escript.html Erlang Escript]. We note that the current version of CLI is a prototype, only discovering opportunities and usefulness of this kind of interface. As the CLI is executable by any os process, !RefactorErl gets invokable from inside any code editor, turning it into a refactoring and comprehension UI. == Installation == If you have successfully downloaded and compiled !RefactorErl (see [wiki:Install How to install the tool]), you have nothing else to install. Before the first usage, you may want to redefine two functions defined in the !RefactorErl EScript: * referlpath() determines the directory path to the tool (''.'' by default) * referlnode() determines the node name the process of the tool will run on (''refactorerl@localhost'' by default) Also, you can make the ''!RefactorErl'' EScript executable. {{{ chmod +x RefactorErl }}} == Usage == Using the CLI is pretty straightforward. You can simply pass the following data to the script as command line arguments: * The name of the module the invoked function is located in * The name of the invoked function * The function arguments For example: {{{ RefactorErl mod fun arg1 arg2 "arg3" }}} will invoke ''mod:fun(arg1, arg2, arg3)'' inside !RefactorErl. Note that arguments containing spaces should be enclosed by double quote marks. ==== Syntactic sugars ==== If the function you would like to execute has no arguments, you can simply type {{{ RefactorErl mod fun }}} If the function you would like to execute is located in the module ''ri'' and takes no arguments, you can simply type {{{ RefactorErl fun }}} === Handling the !RefactorErl server === First of all, if the !RefactorErl server is not running, you should start it up to be able to communicate with. Type {{{ RefactorErl start }}} to start up. This command starts an instance of the tool at the formerly defined node. If the server is already running, you get a message of it. Also, you can stop the previously started !RefactorErl instance. If the server was not running, you will be informed. {{{ RefactorErl stop }}} == Use cases == Resetting the database: {{{ RefactorErl reset RefactorErl ri reset }}} Adding files: {{{ RefactorErl ri add "/path/to/module.erl" }}} Listing database contents: {{{ RefactorErl ri ls }}} Running the query ''mods.funs'' {{{ RefactorErl ri q "mods.funs" }}} Renaming function ''mod:f/1'' to ''g'': {{{ RefactorErl ri renfun mod "{f, 1}" g }}}