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

Function continue_if_modified

std/src/program.rs:116–130  ·  view source on GitHub ↗

If the `program` is dirty, asks if it's OK to continue on `console` and discard its changes.

(
    program: &dyn Program,
    console: &mut dyn Console,
)

Source from the content-addressed store, hash-verified

114
115/// If the `program` is dirty, asks if it's OK to continue on `console` and discard its changes.
116pub async fn continue_if_modified(
117 program: &dyn Program,
118 console: &mut dyn Console,
119) -> io::Result<bool> {
120 if !program.is_dirty() {
121 return Ok(true);
122 }
123
124 match program.name() {
125 Some(name) => console.print(&format!("Current program {} has unsaved changes!", name))?,
126 None => console.print("Current program has unsaved changes and has never been saved!")?,
127 }
128 let answer = read_line(console, "Discard and continue (y/N)? ", "", None).await?;
129 Ok(parse_boolean(&answer).unwrap_or(false))
130}
131
132/// The `DISASM` command.
133pub struct DisasmCommand {

Callers 2

async_execMethod · 0.85
run_repl_loopFunction · 0.85

Calls 5

read_lineFunction · 0.85
parse_booleanFunction · 0.85
is_dirtyMethod · 0.45
nameMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected