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,
)
| 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. |
| 64 | pub 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. |
| 97 | pub async fn run_script<P: AsRef<Path>>( |
no test coverage detected