RingoJS

Module ringo/shell

Provides functions to deal with the Ringo shell / REPL. It allows to start a new Ringo shell programmatically. This module is internally used by every Ringo REPL to interact with the user. The example shows a simple Ringo shell script which prepares an object and opens a shell for live interaction.

Example

#!/usr/bin/env ringo
if (require.main == module) {
  const obj = { 'foo': 'bar' };
  require('ringo/shell').start();
}

// running the script opens a new shell
// with the prepared object available
>> console.dir(obj);
{ foo: 'bar' }

Functions


printError (xcept, errors, verbose)

Parameters

Exception xcept
Array errors
Boolean verbose

printResult (value, writer)

Parameters

Object value
Stream writer

quit (status)

Quit the shell and exit the JVM.

Parameters

Number status

optional integer exit status code (default is 0)


read ()

Read a single character from the standard input.


readln (prompt, echoChar)

Read a single line from the standard input.

Parameters

String prompt

optional prompt to display

String echoChar

character to use as echo, e.g. '*' for passwords or '' for no echo.


start (engine)

Start the shell programmatically. This uses the current thread and thus will not return. You should therefore call this function as the last statement in your script. Terminating the shell will exit the program.

Parameters

RhinoEngine engine

write (args...)

Write 0..n arguments to standard output.

Parameters

*... args...

writeln (args...)

Write 0..n arguments to standard output, followed by a newline.

Parameters

*... args...