shrust
Rust library to create interactive command line shells
Copyright © 2016 Pierre-Henri Symoneaux
THIS SOFTWARE IS DISTRIBUTED WITHOUT ANY WARRANTY Check LICENSE.txt file for more information.
This is currently a work in progress, and the API should be consider unstable. I'll start documenting and releasing to crates.io once a first level of stability has been reached
How to use
Including
More often, you will include the library as a dependency to your project. In order to do this, add the following lines to your Cargo.toml file :
[]
= "0.0.1"
Basic usage
Let's have a look at example dummy.rs :
extern crate shrust;
use ;
use *;
The output of this program would be
λ cargo run --example dummy
Running `target\debug\examples\dummy.exe`
>help
hello : Say 'hello' to the world
help : Print this help
history : Print commands history or run a command from it
quit : Quit
>hello
Hello World !!!
>quit
Attaching data
You can attach data to the shell for usage by commands as seen in data.rs:
let v = Vec new;
let mut shell = new;
shell.new_command;
shell.new_command_noargs;
shell.run_loop;
Output:
λ cargo run --example dummy
Running `target\debug\examples\dummy.exe`
>help
help : Print this help
history : Print commands history or run a command from it
list : List strings
push : Add string to the list
quit : Quit
>push foo
Pushing foo
>push bar
Pushing bar
>list
foo
bar
>quit
Multithreading
TBD...
Additional examples are provided in documentation and in examples directory