Choice Engine 2
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-13 23:16:03 +02:00
src Add docs 2026-09-13 20:23:53 +02:00
.gitignore Initial commit 2026-08-23 02:54:13 +02:00
Cargo.lock bump version 2026-09-13 23:16:03 +02:00
Cargo.toml bump version 2026-09-13 23:16:03 +02:00
Example.toml Example.toml: Finish example dialog 2026-08-23 13:36:01 +02:00
README.md step: initial step functionality 2026-08-23 21:27:11 +02:00

Choice Engine 2

Install

Set up repository

~/.cargo/config.toml:

[registries.sam_git]
index = "https://git.sam302.de/sam/_cargo-index.git"

[net]
git-fetch-with-cli = true

Install with Cargo

$ cargo add choice-engine --registry sam_git

Install manually

Cargo.toml:

[dependencies]
choice-engine = { version = "<VERSION>", registry = "sam_git" }

Quick start

use choice_engine::choice_engine;
use ::choice_engine::choice_engine::{StartupParameters, StateMachine};

fn main() {
    // Startup parameters
    let start_params: StartupParameters = StartupParameters {
        file_location: String::from("dialog.toml"),
        initial_timeline: 0
    };

    // Initialize a new state machine based on your start parameters.
    let mut state_machine: StateMachine = choice_engine::init(&start_params).unwrap();

    // This function returns the next dialog.
    // Run this one time to begin and then every time the user makes a choice.
    choice_engine::step(&mut state_machine);
}

Testing

Description Command
Run all tests without stdout when successful cargo test
Run all tests with stdout cargo test -- --no-capture
Print out timeline tree cargo test read_and_parse_file -- --no-capture