Skip to content

Latest commit

 

History

History
112 lines (83 loc) · 4 KB

rep.1.adoc

File metadata and controls

112 lines (83 loc) · 4 KB

REP(1) Manual Page

NAME

rep - a single-shot nREPL client

SYNOPSIS

rep ['OPTIONS'] 'EXPR' …​

DESCRIPTION

rep connects to a running nREPL server, sends a bit of code, and prints the result.

Unlike other nREPL clients, rep does not try to maintain a persistent connection, meaning that thread-local variables and bindings like *e and *1 will not persist across invocations of rep.

OPTIONS

--

End of options. Useful to send code which starts with a dash.

-h, --help

Show a summary of help options.

-l, --line='[FILE:]LINE[:COLUMN]'

Specify the FILE, LINE number, and COLUMN of the code being evaluated. This is used by for compile errors, exceptions, and metadata on evaluated symbols, so specifying this will improve your error messages.

LINE must be supplied if COLUMN is supplied, but all other combinations
are allowed.
-n, --namespace=NS

Evaluate code in NS. 'ns' forms themselves should be evaluated in 'user' in case they don’t already exist. 'user' is the default.

--no-print=KEY

Do not print KEY. Used to suppress output for one of the keys printed by default, out, err, or value. (See --print.)

--op=OP

Specify an nREPL operation. The default is "eval".

-p, --port='@FILE|@FNAME@RELATIVE|[HOST:]PORT'

If 'FILE' is given, FILE is read for host and port. If 'FNAME' and 'RELATIVE' are given, rep finds a parent directory of 'RELATIVE' which contains 'FNAME' and reads that file. The default is '@.nrepl-port@.', which will find the running nREPL if it was invoked by Leiningen.

--print=KEY[,FD[,FORMAT]]

Print response messages with KEY in them to FD, using FORMAT. In FORMAT, %{key} prints key from the response message, %% prints a literal %, and %n prints a newline. If FD is omitted, 1 (stdout) is used. If FORMAT is omitted, %{KEY} is used. Multiple --print options can be specified and they are collected. The defaults are out,1,%{out}, err,2,%{err}, and value,1,%{value}%n. The first time --print is given on the command-line for KEY, any default formats for KEY are removed. List-valued keys can be printed with %{key,SUBFORMAT}, where SUBFORMAT is evaluated for every element and %. refers to the current element value. If SUBFORMAT is not specified, %.%n is used.

--send=KEY,TYPE,VALUE

Send KEY in request message with VALUE. TYPE can be either string or integer.

-v, --verbose

Dump all messages sent and received.

EXAMPLES

rep '(+ 2 2)'

Evaluate a simple expression in the running nREPL server and print its result.

rep '(clojure.tools.namespace.repl/refresh)'

Cause the running nREPL to reload any files which were changed.

rep -l src/foo/myfile.clj:26:7 -n foo.myfile '(+ 26 99)'

This is how an editor might invoke rep when the user requests evaluation of the form under the cursor. In addition to extracting the form under the cursor, the editor will need some mechanism to extract the file’s namespace for the -n option. rep will print 125, which the editor can display in its echo area, log, scratch buffer, or what not.

rep --op=list-sessions --print=sessions,1,%{sessions,var=%.;%n}

Print the list of the active nREPL sessions on each line, where each line looks like var=d041fed3-522f-4e7a-8da1-4b192eef0a24.

rep --op=slurp --send=url,string,http://eraserhead.net/ --print=body

Use CIDER’s "slurp" operation to retrieve http://eraserhead.net/.

rep --op=format-code "(if true\n(+ 1 1) 42)" --print=formatted-code

Use CIDER’s "format-code" operation.

EXIT STATUS

0

Success

1

One of the expressions given threw an exception.

2

An error occurred while parsing options.

255

Some other kind of exception occurred during processing.

BUGS

Some errors, such as namespace-not-found aren’t reported as exceptions, and rep currently cannot suppress or change their formatting.