Skip to main content

miden_debug/repl/
mod.rs

1#[cfg(feature = "repl")]
2use std::boxed::Box;
3
4mod commands;
5pub(crate) mod engine;
6#[cfg(feature = "python")]
7mod python;
8mod script;
9#[cfg(feature = "repl")]
10mod session;
11
12#[cfg(feature = "repl")]
13use log::LevelFilter;
14#[cfg(feature = "repl")]
15use miden_assembly_syntax::diagnostics::{IntoDiagnostic, Report};
16
17pub use self::script::run_commands;
18#[cfg(feature = "repl")]
19use self::session::ReplSession;
20#[cfg(feature = "repl")]
21use crate::config::DebuggerConfig;
22
23/// Run the REPL debugger with the given configuration.
24#[cfg(feature = "repl")]
25pub fn run(config: Box<DebuggerConfig>, logger: Box<dyn log::Log>) -> Result<(), Report> {
26    run_with_log_level(config, logger, LevelFilter::Trace)
27}
28
29/// Run the REPL debugger with the given configuration and log level filter.
30#[cfg(feature = "repl")]
31pub fn run_with_log_level(
32    config: Box<DebuggerConfig>,
33    logger: Box<dyn log::Log>,
34    max_level: LevelFilter,
35) -> Result<(), Report> {
36    // Install the logger; propagate any failure as a diagnostic so the
37    // session doesn't silently start with a half-installed logger.
38    crate::logger::DebugLogger::install_with_max_level(logger, max_level).into_diagnostic()?;
39
40    let mut session = ReplSession::new(config)?;
41    session.run()
42}