Skip to main content

miden_debug/repl/
mod.rs

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