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

Function run_repl_loop

cli/src/lib.rs:64–94  ·  view source on GitHub ↗

Enters the interactive interpreter. `local_drive` is the optional local drive to mount and use as the default location. `service_url` is the base URL of the cloud service.

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

Source from the content-addressed store, hash-verified

62/// `local_drive` is the optional local drive to mount and use as the default location.
63/// `service_url` is the base URL of the cloud service.
64pub async fn run_repl_loop(
65 console_factory: Box<dyn ConsoleFactory>,
66 signals_chan: (Sender<Signal>, Receiver<Signal>),
67 gpio_pins_spec: Option<&str>,
68 local_drive_spec: &str,
69 service_url: &str,
70) -> Result<i32> {
71 let mut builder = new_machine_builder(console_factory, signals_chan, gpio_pins_spec)?;
72 let console = builder.get_console();
73 let program = Rc::from(RefCell::from(endbasic_repl::editor::Editor::default()));
74 let storage = Rc::from(RefCell::from(Storage::default()));
75 setup_storage(&mut storage.borrow_mut(), local_drive_spec)?;
76
77 let service = Rc::from(RefCell::from(CloudService::new(service_url)?));
78 endbasic_client::add_all(
79 &mut builder,
80 service,
81 console.clone(),
82 storage.clone(),
83 "https://repl.endbasic.dev/",
84 );
85
86 let mut machine = builder
87 .make_interactive()
88 .with_program(program.clone())
89 .with_storage(storage.clone())
90 .build();
91 endbasic_repl::print_welcome(&mut *console.borrow_mut())?;
92 endbasic_repl::try_load_autoexec(&mut machine, console.clone(), storage).await?;
93 Ok(endbasic_repl::run_repl_loop(&mut machine, console, program).await?)
94}
95
96/// Executes the `path` program in a fresh machine.
97pub async fn run_script<P: AsRef<Path>>(

Callers 2

async_app_mainFunction · 0.70
safe_run_repl_loopMethod · 0.50

Calls 10

new_machine_builderFunction · 0.85
print_welcomeFunction · 0.85
try_load_autoexecFunction · 0.85
with_storageMethod · 0.80
with_programMethod · 0.80
make_interactiveMethod · 0.80
setup_storageFunction · 0.70
add_allFunction · 0.50
get_consoleMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected