wiki:CommandLineInterface

Version 1 (modified by manualwiki, 12 years ago) (diff)

--

RefactorErl CLI

This page introduces the Command Line Interface (CLI) of RefactorErl.

We provide the user with an 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 Erlang Escript.

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.

Installation

If you have successfully downloaded and compiled RefactorErl, you have nothing else to install.

Before the first usage, you should redefine two functions defined in the RefactorErl CLI:

  • referlpath() defines the directory path to the tool (. by default)
  • referlnode() defines the node name of the tool (refactorerl@localhost by default)

Also, you should make the RefactorErl EScript executable. You may use a command like

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:

/path/to/refactorerl/bin/RefactorErl mod fun arg1 arg2 "arg3"

will invoke mod:fun(arg1, arg2, arg3) inside RefactorErl.

Note that Erlang terms written with spaces should be enclosed by double quote marks.

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 previously given 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