MCPcopy Index your code
hub / github.com/endbasic/endbasic / run_script

Function run_script

cli/src/lib.rs:97–114  ·  view source on GitHub ↗

Executes the `path` program in a fresh machine.

(
    path: P,
    console_factory: Box<dyn ConsoleFactory>,
    signals_chan: (Sender<Signal>, Receiver<Signal>),
    gpio_pins_spec: Option<&str>,
)

Source from the content-addressed store, hash-verified

95
96/// Executes the `path` program in a fresh machine.
97pub async fn run_script<P: AsRef<Path>>(
98 path: P,
99 console_factory: Box<dyn ConsoleFactory>,
100 signals_chan: (Sender<Signal>, Receiver<Signal>),
101 gpio_pins_spec: Option<&str>,
102) -> Result<i32> {
103 let builder = new_machine_builder(console_factory, signals_chan, gpio_pins_spec)?;
104 let mut machine = builder.build();
105 let mut input = File::open(path)?;
106
107 machine.compile(&mut input)?;
108 match machine.exec().await {
109 Ok(Some(code)) => Ok(code),
110 Ok(None) => Ok(0),
111 Err(StdError::Break) => Ok(INTERRUPTED_EXIT_CODE),
112 Err(e) => Err(e.into()),
113 }
114}
115
116/// Executes the `path` program in a fresh machine allowing any interactive-only calls.
117///

Callers 1

async_app_mainFunction · 0.85

Calls 4

new_machine_builderFunction · 0.85
buildMethod · 0.45
compileMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected