Revolver

A library for building REPL applications.

Crates.io docs.rs Build Status codecov

Concepts

Command

The Command trait is a specification of an executable command — the 'execute' part of a REPL application. A command will typically be accompanied by a NamedCommandParser implementation for converting command strings into Command objects.

Commands and NamedCommandParsers are the only two traits that you must implement. Everything else is just configuration.

Commander

A Commander decodes user input (typically a line read from a terminal interface) into a dynamic Command object, using a preconfigured map of NamedCommandParsers.

Built-in commands

Revolver comes with two useful built-in commands that can be used out-of-the-box.

These commands are opt-in, meaning that you must explicitly include their parsers in your Commander to enable them.

Terminal

The Terminal trait represents a text-based interface with the user. It fulfils the 'read' and 'print' parts of a REPL application.

Revolver is currently bundled with two Terminal implementations:

Looper

Looper is a mechanism for iteratively running commands based on successive user input. It fulfils the 'loop' part of a REPL application.

Getting started

Add dependency

sh cargo add revolver

An example

See examples/calculator.rs for a simple calculator REPL.