sim-run-core 0.1.2

Core command entry API for the SIM bootloader.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use sim_kernel::{Cx, Value};

use crate::CliError;

pub const EXIT_SUCCESS: i32 = 0;
pub const EXIT_FAILURE: i32 = 1;

/// Converts a loaded entrypoint result into a process exit code.
pub fn value_to_exit_code(cx: &mut Cx, value: Value) -> Result<i32, CliError> {
    value
        .object()
        .truth(cx)
        .map(|success| if success { EXIT_SUCCESS } else { EXIT_FAILURE })
        .map_err(|err| CliError::new(format!("convert CLI result to exit code: {err}")))
}