Command Engine
Transform string instructions into code execution.
Engine
This crate provides a default engine, that is present if default features are enabled. It is simply a container for your Commands that can also execute them based on the input.
There are 2 versions of the default Engine:
sync
- Default.async
- Enabled withasync
feature.
Instruction
The given input is deserialized into a specific format defined in Instruction
structure.
It allows for one Command caller
, multiple positional args
, additional o_args
which act like flags
that can contain sub_args
.
Format:
<caller> <arg> <arg> --<o_arg> <sub_arg> <sub_arg> --<o_arg>
Example:
example argument1 argument2 --flag2 child1 child2 --flag3 --flag1
Deserializes to:
Instruction ;
To add spaces in arguments use double quotes "
:
example "argument 1" "--flag 2" "child 1"
If there are double quotes in the argument it's suggested to use collector #
:
example #"argument "quotes" 1"#
There are no escape characters to avoid any heap allocations. Each argument is a string slice taken from the input.
Example
Sync version:
use *;
;
Disclaimer
ToDo (in future):
- Custom Instructions (just like the Outputs)
- Integrated help command
Versioning:
*.*.*
- Released.*.*.*-rc.*
- Release Candidate.*.*.*-dev
- Unreleased in production.0.*.*
- Deprecated.