Crates.io | interactive-actions |
lib.rs | interactive-actions |
version | 1.0.1 |
source | src |
created_at | 2022-08-07 09:31:34.402188 |
updated_at | 2023-03-03 08:39:58.08135 |
description | Run actions and interactions defined declaratively |
homepage | |
repository | https://github.com/jondot/interactive-actions |
max_upload_size | |
id | 640161 |
size | 45,083 |
This is a Rust library that runs actions and interactions that are defined declaratively.
[dependencies]
interactive-actions = "1"
For most recent version see crates.io
Run the example:
$ cargo run --example interaction
Finished dev [unoptimized + debuginfo] target(s) in 0.30s
Running `target/debug/examples/interaction`
start
✔ are you ready to start? · Yes
city
✔ input a city · goo
transport
✔ pick a transport · bus
+ cd projects/interactive-actions
+ echo go for goo on a bus
go for goo on a bus
Create a Vec<Action>
, here described in YAML, but you can either build it in Rust or any Deserialize
format:
- name: city
interaction:
kind: input
prompt: input a city
out: city
And run it:
use interactive_actions::{data::{Action, ActionHook}, ActionRunner};
let actions: Vec<Action> = serde_yaml::from_str(YAML).unwrap();
let mut runner = ActionRunner::default();
let res = runner.run(
&actions,
None,
ActionHook::After,
Some(|action: &Action| {
println!("{}", action.name);
}),
);
Copyright (c) 2022 @jondot. See LICENSE for further details.