MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / run

Function run

cli/src/repl.rs:15–56  ·  view source on GitHub ↗
(manifest_path: &Path)

Source from the content-addressed store, hash-verified

13const CONT: &str = "... ";
14
15pub fn run(manifest_path: &Path) -> Result<()> {
16 let manifest = Manifest::load(manifest_path)?;
17 let mut session = Session::open(&manifest)?;
18 println!("Edge Python {} · .exit, Ctrl+C or Ctrl+D to quit", env!("CARGO_PKG_VERSION"));
19
20 let mut rl = DefaultEditor::new()?;
21 loop {
22 let first = match rl.readline(PROMPT) {
23 Ok(s) => s,
24 Err(ReadlineError::Interrupted) => break, // Ctrl+C exits
25 Err(ReadlineError::Eof) => break, // Ctrl+D exits
26 Err(e) => { eprintln!("repl error: {e}"); break; }
27 };
28 let _ = rl.add_history_entry(first.as_str());
29 let block = match read_block(&mut rl, first)? {
30 BlockResult::Done(b) => b,
31 BlockResult::Exit => break,
32 };
33
34 let trimmed = block.trim();
35 if trimmed.is_empty() { continue; }
36 match trimmed {
37 ".exit" => break,
38 ".reset" => {
39 // Wipe runtime modules in place; the browser keeps running.
40 session.reset()?;
41 continue;
42 }
43 _ => {}
44 }
45
46 let outcome = session.eval(&block, crate::engine::emit_chunk)?;
47 // `raise SystemExit` quits the session with its code, matching the one-shot runner.
48 if let Some(code) = outcome.exit_code {
49 std::process::exit(code);
50 }
51 if let Some(err) = outcome.err {
52 crate::ui::traceback(&err);
53 }
54 }
55 Ok(())
56}
57
58enum BlockResult {
59 Done(String),

Callers 2

mainFunction · 0.70
run_scriptFunction · 0.70

Calls 7

loadFunction · 0.85
read_blockFunction · 0.85
tracebackFunction · 0.85
resetMethod · 0.80
evalMethod · 0.80
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected