-
Notifications
You must be signed in to change notification settings - Fork 218
REPL Console Customization
REPL console is customized by using init script, config files and console variables. In order to work correctly some JLine commands and configurations require that application ConfigurationPath has been set in application startup.
Application console enviroment is initialized using SystemRegistry method initialize(File initScript)
. Initialization script can be used to create:
- custom pipes
- command and pipe aliases
- custom widgets and key bindings
-
prnt
command default options and highlight rules
An initialization script example, see REPL demo init.jline.
A list of directories from where ConsoleEngine
is searching scripts.
A map that contains console options:
-
maxValueNames maximum number of pipeline names that are persisted so that they can be reused in later sessions. Pipeline names are used by
PipelineCompleter
to offer tab completions. -
no-splittedOutput as a default
ConsoleEngine
will split multiline command output to the String array. This will facilate the use of pipe operations. -
trace
ConsoleEngine
trace level. Valid values: 0 - 2. Default value 0 (no trace).
The command prnt
can use Nano SyntaxHighlighter to highlight object output. The nanorc configuration file is searched from
-
ConfigurationPath
: jnanorc file is first looked from the user-config path, if the file is not found then it is looked from the application-config path. - NANORC console variable: full name of the nanorc file
- /etc/nanorc
A map that contains prnt
command default options.
In a console the evaluated command result is converted to the Map<String,Object>
or in a case of collection to the List<Map<String,Object>>
before printing it to the console. The collection result is printed out as a table if the collection map key sets match sufficiently well with each other. If the collection map key sets differ too much the original result list (List<Object>
) is used and the list elements are printed using the result of the ScriptEngine
method toString(Object object)
.
In addition to the prnt
command options REPL console print method has some 'hidden' options that can be used to customize object printing:
- columnsIn, a list of map keys. These map values will be added to the table before all the other keys.
- columnsOut, a list of map keys. These map values will not be inserted to the table.
-
highlightValue, a
map<regex, function>
. If command result map key matches with regex the highlight function is applied to the corresponding map value. The regex =*
is processed after all the other regexes and the highlight function will be applied to all map values that have not been already highlighted. - mapSimilarity default value 0.8 i.e. if at least of 4 of the 5 results map keys match with reference key set the result will be printed out as a table.
-
objectToMap, a
map<class, function>
. Overrides theScriptEngine
toMap()
method. -
objectToString, a
map<class, function>
. Overrides theScriptEngine
toString()
method.