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,
)
| 114 | |
| 115 | /// If the `program` is dirty, asks if it's OK to continue on `console` and discard its changes. |
| 116 | pub 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. |
| 133 | pub struct DisasmCommand { |
no test coverage detected