Shelp
shelp
(sh help
) is a library to create a functional and good looking REPL without having to worry about
the generic setup and interacting and the terminal. It provides a configurable interface,
allowing you to only need to deal with the language specific parts of the REPL.
There are special 2 commands handled by the repl:
clear
- clears the screenexit
- exits These can be changed with therepl.set_clear_keyword()
andrepl.set_exit_keyword()
respectively. Any other special commands can be handled within the execution loop.
How to use
Take some program that just prints the input back:
use ;
let repl = newd;
let mut repl = repl.iter;
// Now 'claer' clears the screen instead of 'clear'.
repl.set_clear_keyword;
for command in repl
Here no LangInterface
is specified, so the default is used.
A LangInterface
can be specified by implementing the trait and passing it as the generic
type argument.
use ;
use ;
// You can use any library, but currently only crossterm is used in the library for terminal.
use Colorize;
;
// We want to override the linting so numbers are coloured, but we don't have a specific way of
// getting the indentation, so we do not override that.
// Use a particular capacity
let mut repl = with_capacity;
loop