implement Exit/Delete

This commit is contained in:
Quaternions 2023-09-12 19:28:13 -07:00
parent 7ab20f36a7
commit 52d911a25a

View File

@ -328,10 +328,13 @@ enum ScriptAction {
Replace(u32),
Flag,
Block,
Delete,
}
enum ScriptActionParseResult {
Pass,
Block,
Exit,
Delete,
}
struct ParseScriptActionErr;
impl std::str::FromStr for ScriptActionParseResult {
@ -341,6 +344,10 @@ impl std::str::FromStr for ScriptActionParseResult {
Ok(Self::Pass)
}else if s=="block\n"{
Ok(Self::Block)
}else if s=="exit\n"{
Ok(Self::Exit)
}else if s=="delete\n"{
Ok(Self::Delete)
}else{
Err(ParseScriptActionErr)
}
@ -355,7 +362,7 @@ fn interactive() -> Result<(), Box<dyn std::error::Error>>{
let mut replace_map=get_replace_map()?;
let mut blocked = get_blocked()?;
for entry in std::fs::read_dir("maps/unprocessed")? {
'map_loop: for entry in std::fs::read_dir("maps/unprocessed")? {
let file_thing=entry?;
println!("processing map={:?}",file_thing.file_name());
let input = std::io::BufReader::new(std::fs::File::open(file_thing.path())?);
@ -436,6 +443,8 @@ fn interactive() -> Result<(), Box<dyn std::error::Error>>{
id+=1;
ScriptAction::Block
},
ScriptActionParseResult::Exit => break 'map_loop,
ScriptActionParseResult::Delete => ScriptAction::Delete,
}
};
@ -451,7 +460,12 @@ fn interactive() -> Result<(), Box<dyn std::error::Error>>{
}else{
panic!("failed to get replacement source id={} location={}",replace_id,location);
}
}
},
ScriptAction::Delete => {
println!("deleted source location={}",get_full_name(&dom, script));
replace_count+=1;
dom.destroy(script.referent());
},
ScriptAction::Flag => {
println!("flagged source location={}",get_full_name(&dom, script));
fail_type=Interactive::Flagged;