krush-engine: The engine that powers the Kreative Rust Shell
The krush-engine is a library that has a simple command parser and interpreter that is used for the krush shell interface, but can be used standalone.
What it does?
Once you've defined an Engine with all the commands you want using the register_command method. You can call the method evaluate with a String which returns a Result. The first word of this string is the command name, if you've registered a command with that name, the Engine will parse the rest of the input to get the arguments you've setted. If everything goes right, your callback function will be called.
TODO
- List of any Type
- Support quoted strings in List
Note
This project were written in a day to be used for my homework so there are several unimplemented features and potential bugs (actually, krush doesn't even exists at the moment).
Changelog
v0.3.0
- Now a Engine can be captured by a thread closure
- Values captured by a definition closure must be Arc<Mutex>
- A defition closure must be a
moveclosure
v0.2.0
- Now a Definition uses a closure instead of a function pointer, which allows to modify values in the surrounding context by putting them into
CellorRefCell(for types who doesn't implement theCopytrait) - Added
definition!macro which creates a newDefinitionfrom an array ofTypeand a closure.
Example:
use ;
use ;
Output:
Hello World!
Last is: Hello World!
This is Krush Engine!
Last is: This is Krush Engine!
Thank You!
Last is: Thank You!
Count is 3