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

Rental Turnaround

Bind returned equipment to its rental ID and require cleaning or repair before reissue.

Source repository · Package JSON

Use Rental Turnaround

use vendor::rental_turnaround::rental_turnaround;

Run the example

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

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 = rental_turnaround_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 = rental_turnaround_step(live, args_at(arguments, i), text_number(input));
            let command = rental_turnaround_command(live);
            println!(command);
            if command == "reject" { process_exit(1); }
            i += 2;
        }
        return;
    }
    let mut state = rental_turnaround_start();
    state = rental_turnaround_step(state, "issue", 8.0);
    println!(rental_turnaround_command(state));
    state = rental_turnaround_step(state, "returned", 8.0);
    println!(rental_turnaround_command(state));
    state = rental_turnaround_step(state, "damage", 0.0);
    println!(rental_turnaround_command(state));
    state = rental_turnaround_step(state, "fixed", 0.0);
    println!(rental_turnaround_command(state));
    state = rental_turnaround_step(state, "checked", 0.0);
    println!(rental_turnaround_command(state));
}

Expected output

mark_rented
inspect_item
create_workorder
clean_item
mark_available

Published versions

VersionPackageSource commitSHA-256
0.1.2Download ZIP · Browse filesae7316841762d13e7f0f17d96eb0335ecb4e696d23061a5d4a45457d0424904b1fd53bfc92
0.1.1Download ZIP · Browse filesefb66980dfeed93089b280913dd027542bc927689e168c7ece68dbe6cd97d0ef457db32368
0.1.0Download ZIP · Browse files6349f237845ff16cadb577154c3e28b379ad5f41f5192b0ab8943b7ca8b6dae9bd7d019a54