Shellfish
Shellfish is a library to include interactive shells within a program. This may be useful when building terminal application where a persistent state is needed, so a basic cli is not enough; but a full tui is over the scope of the project. Shellfish provides a middle way, allowing interactive command editing whilst saving a state that all commands are given access to.
The shell
By default the shell contains only 3 built-in commands:
help
- displays help information.quit
- quits the shell.exit
- exits the shell.
The last two are identical, only the names differ.
When a command is added by the user (see bellow) the help is automatically generated and displayed. Keep in mind this help should be kept rather short, and any additional help should be through a dedicated help option.
Example
The following code creates a basic shell, with the added command of greet
which requires one argument, and if not given returns an error. It is as follows:
use Command;
use Shell;
use Error;
use fmt;
/// Greets the user
/// Greeting error
;