Blyx Nest Blyx language
Registry / Framework
framework · v0.1.2

Chapter Lock

Prevent a book export from racing a new chapter edit by sealing a numbered manuscript snapshot.

Source repository · Package JSON

Use Chapter Lock

use vendor::chapter_lock::chapter_lock;

Run the example

nest demo chapter_lock@0.1.2
blyxc native-run chapter_lock-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::chapter_lock::chapter_lock;

fn main() {
    let arguments = cli_args();
    if args_len(arguments) > 0 {
        if args_len(arguments) % 2 != 0 {
            stderr_line("Expected event and value pairs");
            process_exit(2);
        }
        let mut live = chapter_lock_start();
        let mut i = 0;
        while i < args_len(arguments) {
            let input = args_at(arguments, i + 1);
            if !text_is_number(input) {
                stderr_line("Expected a whole numeric event value");
                process_exit(2);
            }
            live = chapter_lock_step(live, args_at(arguments, i), text_number(input));
            let command = chapter_lock_command(live);
            println!(command);
            if command == "reject" { process_exit(1); }
            i += 2;
        }
        return;
    }
    let mut state = chapter_lock_start();
    state = chapter_lock_step(state, "edit", 2.0);
    println!(chapter_lock_command(state));
    state = chapter_lock_step(state, "seal", 2.0);
    println!(chapter_lock_command(state));
    state = chapter_lock_step(state, "export", 2.0);
    println!(chapter_lock_command(state));
    state = chapter_lock_step(state, "finish", 1.0);
    println!(chapter_lock_command(state));
    state = chapter_lock_step(state, "finish", 2.0);
    println!(chapter_lock_command(state));
}

Expected output

record_revision
freeze_manuscript
render_book
reject
index_edition

Published versions

VersionPackageSource commitSHA-256
0.1.2Download ZIP · Browse filescff5ef95c9ce5a2c7d3942dc5b33de8e4d41127a2e5469e9aa3b2d2044f32079dd08fc9660
0.1.1Download ZIP · Browse filesff8776963927b53348a64f76130fbc9755414d915d6b27be0f8fb26eeb87e50b80c21a249f
0.1.0Download ZIP · Browse files6349f23784d0a3ef0ac508e788a331da8f5afbb741489ecce8b80e3988668063aaf5748f75