Skip to content

Commit c199fbf

Browse files
committed
Update REPL command parsing
1 parent 5b22bec commit c199fbf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,17 @@ fn process(
213213
// Let's do a sanity check before going forward.
214214
let _ = chalk_prog.db.checked_program()?;
215215
*prog = Some(chalk_prog);
216-
} else if command.starts_with("load ") {
216+
} else if let Some(filename) = command.strip_prefix("load ") {
217217
// Load a .chalk file.
218-
let filename = &command["load ".len()..];
219218
let chalk_prog = load_program(args, filename)?;
220219
// Let's do a sanity check before going forward.
221220
let _ = chalk_prog.db.checked_program()?;
222221
*prog = Some(chalk_prog);
223-
} else if command.starts_with("debug ") {
224-
match command.split_whitespace().nth(1) {
225-
Some(level) => std::env::set_var("CHALK_DEBUG", level),
226-
None => println!("debug <level> set debug level to <level>"),
222+
} else if let Some(level) = command.strip_prefix("debug ") {
223+
if level.is_empty() {
224+
println!("debug <level> set debug level to <level>");
225+
} else {
226+
std::env::set_var("CHALK_DEBUG", level);
227227
}
228228
} else {
229229
// The command is either "print", "lowered", or a goal.

0 commit comments

Comments
 (0)